npm install --save-dev eslint@^9 @1024pix/eslint-pluginconst pixEslintConfig = require('@1024pix/eslint-plugin/config');
module.exports = pixEslintConfig;Note that this ESLint config is not ready to use with ESM.
For example:
{
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix"
}
}Install VS Code ESLint extension and create .vscode/settings.json
{
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": false
}
}These rules are shipped by the plugin but not enabled by the shared config.
Reports an equality lookup (find, filter, findIndex, some, every…) nested in a loop when it compares against a variable of that loop. Such a join costs O(n × m).
// ✗ one scan of `rows` per id
ids.map((id) => rows.find((row) => row.id === id));
// ✓ one pass to index, then one read per id
const rowsById = new Map(rows.map((row) => [row.id, row]));
ids.map((id) => rowsById.get(id));Enable it where both collections grow with the data, for example:
{
files: ['src/**/repositories/**/*.js', 'src/**/usecases/**/*.js'],
rules: { '@1024pix/no-linear-lookup-in-loop': 'error' },
}Sure, you can override the rules in your eslint.config.js file.
const pixEslintConfig = require('@1024pix/eslint-plugin/config');
module.exports = [
...pixEslintConfig,
{
rules: {
// your rules...
},
},
];Or you can always fork this repo and make your own.
Before v1.2.0, Pix Config was provided by the @1024pix/eslint-config project.
After upgrading, you should migrate from the old .eslintrc files to the new eslint.config.cjs file format.
Take a look at the official ESLint migration guide. You can also take inspiration from this Pix context example.
Once finished, @1024pix/eslint-config can safely be removed.