This package provides Cognizant Netcentric's ESLint configuration as an extensible shared config.
If ESLint is new to you, you might want to check out what it does and how to configure it.
- ESLint
^9.0.0 - Node.js
^18.18.0 || ^20.9.0 || >=21.1.0
npm i -D eslint@9 @netcentric/eslint-configThis package exports an ESLint flat config array. Create an eslint.config.js (or eslint.config.mjs if your project is not an ES module) file:
import netcentric from '@netcentric/eslint-config';
export default [
...netcentric
];Most IDEs should have an integration for ESLint.
If you are using https://github.com/Netcentric/fe-build, ESLint is integrated by default.
For custom lint task, update package.json
"scripts": {
"lint:js": "eslint path/to/source-js-files"
}Make sure you do not accidently lint files you are not interested that are out of scope for your build; e.g. files within the node_modules folder.
- Only ESLint v9 flat config is supported. Replace your
.eslintrcwith aneslint.config.jsas shown in Setup. - The package is now ESM-only.
- The Airbnb rules are now provided by eslint-config-airbnb-extended (legacy config), a maintained drop-in replacement for
eslint-config-airbnb-base. ecmaVersionis nowlatest(was2020).- ESLint v9 changed the defaults of some rules:
no-unused-vars: unusedcatchparameters are now reported. Usecatch {}without a binding instead.no-inner-declarations: function declarations inside blocks are now allowed in strict mode (ES modules).no-useless-computed-key: unnecessary computed keys in classes are now reported.no-constant-condition:while (true)loops are no longer reported.
This config now warns about unsorted imports (import/order). Warnings will become errors in a future release, giving teams time to adopt the rule gradually.
To auto-fix all import order warnings in your project at once, run:
npx eslint --fix path/to/source-js-filesPlease stick to the Netcentric rules as they are battle tested and were created to form a company wide basis for JS code quality. If there's a very specific case you want to deactivate a rule for consider using Eslint inline comments instead.
If there's a rule you consider as outdated or simply wrong please contact the package's maintainer or file an issue in JIRA (bugs in package.json) or create a PR on the package's repository (repository in package.json).
If you have a very project specific case where adding or deactivating a rule makes perfectly sense, you can overwrite any rule by appending a config object:
import netcentric from '@netcentric/eslint-config';
export default [
...netcentric,
{
rules: {
'no-console': 'off'
}
}
];You can find a description of all rules on the Eslint Homepage.