# Please add node to default eslint configuration in nrlint

**URL:** <https://discourse.nodered.org/t/please-add-node-to-default-eslint-configuration-in-nrlint/63673>\
**Category:** Feature Requests\
**Created:** [9 June 2022 12:14 UTC](https://discourse.nodered.org/t/please-add-node-to-default-eslint-configuration-in-nrlint/63673 "2022-06-09T12:14:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![parasaurolophus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/parasaurolophus/32/18729_2.png) [@parasaurolophus](https://discourse.nodered.org/u/parasaurolophus)\
**Post date:** [9 June 2022 12:14 UTC](https://discourse.nodered.org/t/please-add-node-to-default-eslint-configuration-in-nrlint/63673/1 "2022-06-09T12:14:00Z")

</div>

Adding `"node": true` to the `"env"` section of the eslint configuration file prevents spurious warnings such as when calling the global `setTimeout()` function. E.g.:

```
"env": {
    "es2021": true,
    "node": true
},

```

I am using the latest development version of nrlint on the master branch and the default eslint configuration does not include "node"

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 June 2022 12:33 UTC](https://discourse.nodered.org/t/please-add-node-to-default-eslint-configuration-in-nrlint/63673/2 "2022-06-09T12:33:22Z")

</div>

Best eslint for node.js v12 development is something like this:

```auto
/** JavaScript Versions
 * 5 is minimum -> Last IE11
 * 6 = 2015 -> Node >8.10, iOS12+
 * 7 = 2016 -> FF78+,
 * 8 = 2017 -> Node 10.9+
 * 9 = 2018 -> Node 12.11+
 * 10 = 2019 -> Node 12.20 LTS
 * 11 = 2020 -> Node 14 LTS
 * 12 = 2021 -> Node 16
 */
/** Node.js supports (https://node.green/):
 * v07 - async/await
 * v09 - tagged template literals with invalid escape sequences, RegExp lookbehind assertions
 * v10 - optional catch binding (no need for err param on catch), BigInt, import.meta,
 * RegExp Unicode property escape sequences \p{...},
 * trimStart/trimEnd, async iteration, Promise.prototype.finally,
 * RegExp named capture groups
 * v11 - Array.prototype.{flat,flatMap}, Symbol.prototype.description
 * v12 - Promise.allSettled, globalThis, numeric separators, Object.fromEntries
 * v13 - import (modules), dynamic import(), export
 * v14 - optional chaining, Nullish Coalescing operators, String.prototype.matchAll,
 * Intl.DisplayNames, Intl.DateTimeFormat, Async Local Storage, Top-Level Await, Diagnostic report,
 * WeakReferences, private class methods
 * v15 - logical assignment operators, String.prototype.replaceAll, Promise.any, AggregateError, AbortController,
 * Promisified setTimeout/setImmediate
 */
module.exports = {
    env: {
        browser: false,
        commonjs: true,
        jquery: false,
        node: true,
        'shared-node-browser': false
    },
    parserOptions: {
        // Only ESLint 6.2.0 and later support ES2020. Node.js v12+ supports some things only ratified in 2020
        'ecmaVersion': 2022,
        sourceType: 'script'
    },
    extends: [
        'standard',
        'plugin:es/restrict-to-es2019',
        // The n plugin reads the min. node.js version from package.json and error's any ES features not available in that version.
        'plugin:n/recommended',
    ],
   rules: {
        // remove once min engines moves to node.js v14+
        'es/no-optional-chaining': 'error',
        'es/no-dynamic-import': 'error',
        'es/no-nullish-coalescing-operators': 'error',
        // remove once min engines moves to node.js v15+
        'es/no-logical-assignment-operators': 'error',
        'es/no-promise-any': 'error',
        'es/no-numeric-separators': 'error',
    }
}

```

You will need the es and `n` extensions for eslint. I've used standard here, you may prefer something else. I also have some JSDoc enhancements and some anti-standard annoyance settings as well.

Node.js v12+ supports a number of things that were only actually ratified in the 2022 version of JavaScript which is why you need to jump through hoops.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 August 2022 12:33 UTC](https://discourse.nodered.org/t/please-add-node-to-default-eslint-configuration-in-nrlint/63673/3 "2022-08-08T12:33:42Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
