@ornikar/eslint-config 22.7.4 → 23.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,105 +15,76 @@ Also see:
15
15
 
16
16
  ## How to install
17
17
 
18
- These configs ship as flat-config arrays. Require the subpath you need and spread it into your `eslint.config.js`.
19
-
20
18
  ### root
21
19
 
22
20
  1. `npm install --save-dev eslint @ornikar/eslint-config`
23
- 2. In your root `eslint.config.js`:
24
-
25
- ```js
26
- const ornikarRoot = require('@ornikar/eslint-config/root');
27
-
28
- module.exports = [...ornikarRoot];
29
- ```
21
+ 2. Add `"extends": ["@ornikar/eslint-config/root"]` to your eslint config
30
22
 
31
23
  ### node without babel or typescript
32
24
 
33
25
  1. `npm install --save-dev eslint @ornikar/eslint-config`
34
- 2. In your source `eslint.config.js`:
35
-
36
- ```js
37
- const ornikarNode = require('@ornikar/eslint-config/node');
38
-
39
- module.exports = [...ornikarNode];
40
- ```
26
+ 2. Add `"extends": ["@ornikar/eslint-config", "@ornikar/eslint-config/node"]` to your eslint config
41
27
 
42
28
  ### node with babel (deprecated, please use typescript instead)
43
29
 
44
30
  1. `npm install --save-dev eslint @ornikar/eslint-config @ornikar/eslint-config-babel`
45
- 2. In your source `eslint.config.js`:
46
-
47
- ```js
48
- const babelConfig = require('@ornikar/eslint-config-babel');
49
-
50
- module.exports = [...babelConfig];
51
- ```
31
+ 2. Add `"extends": ["@ornikar/eslint-config-babel", "@ornikar/eslint-config/node""]` to your eslint config
52
32
 
53
33
  ### node with typescript
54
34
 
55
35
  1. `npm install --save-dev eslint @ornikar/eslint-config @ornikar/eslint-config-typescript`
56
- 2. In your source `eslint.config.js`:
57
-
58
- ```js
59
- const tsNode = require('@ornikar/eslint-config-typescript/node');
60
-
61
- module.exports = [...tsNode];
62
- ```
36
+ 2. Add `"extends": ["@ornikar/eslint-config-typescript", "@ornikar/eslint-config/node"]` to your eslint config
63
37
 
64
38
  ### module override
65
39
 
66
- In flat config, file-specific overrides are separate entries with `files:`. Use `defineConfig` from `eslint/config` so the `extends:` keyword works:
67
-
68
- ```js
69
- const { defineConfig } = require('eslint/config');
70
- const ornikarRoot = require('@ornikar/eslint-config/root');
71
- const nodeModuleOverride = require('@ornikar/eslint-config/node-module-override');
72
-
73
- module.exports = defineConfig([
74
- ...ornikarRoot,
75
- {
76
- files: ['test-setup.js'],
77
- extends: [nodeModuleOverride],
78
- },
79
- ]);
40
+ ```json
41
+ {
42
+ "root": true,
43
+ "extends": ["@ornikar/eslint-config/root"],
44
+ "overrides": [
45
+ {
46
+ "files": ["test-setup.js"],
47
+ "extends": ["@ornikar/eslint-config/node-module-override"]
48
+ }
49
+ ]
50
+ }
80
51
  ```
81
52
 
82
53
  ## How to configure a project
83
54
 
84
- ### Two configuration files
55
+ ### Two configurations files
85
56
 
86
- In a project you should have two configuration files:
57
+ In a project you should have two configurations files:
87
58
 
88
- - /eslint.config.js
89
- - /{src,lib}/eslint.config.js
59
+ - /.eslintrc.json
60
+ - /{src,lib}/.eslintrc.json
90
61
 
91
62
  If the project is compiled, use `src` for source and `dist` for compilation with rollup.
92
63
  If the project is not compiled, use `lib`.
93
- If the project is CRA, next or built with webpack, use `src` for source and `build` or the build directory your tool uses.
64
+ If the project is CRA, next or build with webpack, use `src` for source and `build` or the build directory your tool uses.
94
65
 
95
66
  Using two config files is important:
96
67
 
97
- - the root config is for config files and scripts. It should allow dev dependencies
98
- - the source config is for your source and test files
68
+ - the root eslintrc is for config files and scripts. It should allow dev dependencies
69
+ - the source eslintrc is for your source and tests files.
99
70
 
100
- ESLint v9 flat config does not cascade like legacy `.eslintrc` did — only the nearest `eslint.config.js` to the file being linted is used. Compose what you need at each location.
71
+ ### Use `"root": true`
101
72
 
102
- ### Use `ignores`
73
+ Both the configuration shoud set `"root": true` to prevent eslint to merge the config file with other higher eslintrc configs. See [Cascading and hierarchy](https://eslint.org/docs/user-guide/configuring/configuration-files#cascading-and-hierarchy) in eslint config documentation.
103
74
 
104
- Replace `.eslintignore` with the `ignores` property in your flat config:
75
+ The advantage of using 2 config files is to avoid overriding rules set for root. For example, root config should use plugin node, but not always your source config !
105
76
 
106
- ```js
107
- module.exports = [{ ignores: ['dist/**', 'coverage/**'] }, ...ornikarRoot];
108
- ```
77
+ ### Use `ignorePatterns` in .eslintrc.json
78
+
79
+ Use `ignorePatterns` instead of .eslintignore file. We have enough configuration files !
109
80
 
110
81
  ### Use `--report-unused-disable-directives`
111
82
 
112
- Really useful tip it prevents leaving unused eslint-disable directives.
83
+ Really usefull tip, it prevents leaving unused eslint-disable directives.
113
84
 
114
- ### Lerna/Workspaces configuration
85
+ ### Lerna/Workspaces Configuration
115
86
 
116
- Assuming your `package.json` has `"workspaces": ["packages/*"]`:
87
+ Assuming your package.json looks like `"workspaces": ["packages/*"]`:
117
88
 
118
- - /eslint.config.js
119
- - /packages/\*/{src,lib}/eslint.config.js
89
+ - /.eslintrc.json
90
+ - /packages/\*/{src,lib}/.eslintrc.json
package/_shared.js CHANGED
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const bestPractices = require('./rules/best-practices');
4
- const imports = require('./rules/imports');
5
- const ornikar = require('./rules/ornikar');
6
- const security = require('./rules/security');
7
- const sortImportsExports = require('./rules/sort-imports-exports');
8
- const style = require('./rules/style');
9
- const unicorn = require('./rules/unicorn');
10
-
11
- module.exports = [...bestPractices, ...ornikar, ...imports, ...style, ...sortImportsExports, ...security, ...unicorn];
3
+ module.exports = {
4
+ extends: [
5
+ './rules/best-practices',
6
+ './rules/ornikar',
7
+ './rules/imports',
8
+ './rules/style',
9
+ './rules/sort-imports-exports',
10
+ './rules/security',
11
+ './rules/unicorn',
12
+ ].map(require.resolve),
13
+ };
package/graphql.js CHANGED
@@ -1,15 +1,13 @@
1
1
  'use strict';
2
2
 
3
- module.exports = [
4
- {
5
- rules: {
6
- // https://eslint.org/docs/rules/no-underscore-dangle
7
- 'no-underscore-dangle': [
8
- 'error',
9
- {
10
- allow: ['__typename'],
11
- },
12
- ],
13
- },
3
+ module.exports = {
4
+ rules: {
5
+ // https://eslint.org/docs/rules/no-underscore-dangle
6
+ 'no-underscore-dangle': [
7
+ 'error',
8
+ {
9
+ allow: ['__typename'],
10
+ },
11
+ ],
14
12
  },
15
- ];
13
+ };
package/index.js CHANGED
@@ -1,29 +1,21 @@
1
1
  'use strict';
2
2
 
3
- const { FlatCompat } = require('@eslint/eslintrc');
4
- const sharedConfig = require('./_shared');
5
- const prettierConfig = require('./rules/prettier');
3
+ module.exports = {
4
+ extends: ['eslint-config-airbnb-base', './_shared', './rules/prettier'].map(require.resolve),
6
5
 
7
- const compat = new FlatCompat({ baseDirectory: __dirname });
6
+ parserOptions: {
7
+ sourceType: 'script',
8
+ ecmaVersion: 2021,
9
+ },
8
10
 
9
- module.exports = [
10
- ...compat.extends('eslint-config-airbnb-base'),
11
- ...sharedConfig,
12
- ...prettierConfig,
13
- {
14
- languageOptions: {
15
- sourceType: 'script',
16
- ecmaVersion: 2021,
17
- },
18
- rules: {
19
- strict: ['error', 'safe'],
20
- 'import/extensions': [
21
- 'error',
22
- 'ignorePackages',
23
- {
24
- js: 'never',
25
- },
26
- ],
27
- },
11
+ rules: {
12
+ strict: ['error', 'safe'],
13
+ 'import/extensions': [
14
+ 'error',
15
+ 'ignorePackages',
16
+ {
17
+ js: 'never',
18
+ },
19
+ ],
28
20
  },
29
- ];
21
+ };
@@ -1,16 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const nPlugin = require('eslint-plugin-n');
4
- const nodeOverride = require('./rules/node-override');
5
-
6
3
  /* prefer usage of .mjs files over this override */
7
- module.exports = [
8
- nPlugin.configs['flat/recommended-module'],
9
- ...nodeOverride,
10
- {
11
- languageOptions: {
12
- // top level await is introduced in ecmaVersion: 2022 but supported since node 14
13
- ecmaVersion: 2022,
14
- },
4
+ module.exports = {
5
+ extends: ['plugin:n/recommended-module', require.resolve('./rules/node-override')],
6
+ parserOptions: {
7
+ // top level await is introduced in ecmaVersion: 2022 but supported since node 14
8
+ ecmaVersion: 2022,
15
9
  },
16
- ];
10
+ };
package/node.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const nodeRules = require('./rules/node');
4
- const prettierConfig = require('./rules/prettier');
5
- const indexConfig = require('.');
6
-
7
- module.exports = [...indexConfig, ...nodeRules, ...prettierConfig];
3
+ module.exports = {
4
+ extends: ['.', './rules/node', './rules/prettier'].map(require.resolve),
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornikar/eslint-config",
3
- "version": "22.7.4",
3
+ "version": "23.0.0",
4
4
  "description": "eslint config files",
5
5
  "repository": {
6
6
  "directory": "@ornikar/eslint-config",
@@ -16,8 +16,7 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@eslint/eslintrc": "^3.3.5",
20
- "@ornikar/eslint-plugin-ornikar": "22.7.4",
19
+ "@ornikar/eslint-plugin-ornikar": "23.0.0",
21
20
  "eslint-config-airbnb-base": "^15.0.0",
22
21
  "eslint-config-prettier": "^10.0.0",
23
22
  "eslint-import-resolver-typescript": "^4.4.4",
@@ -38,6 +37,6 @@
38
37
  "prettier": "2.8.8"
39
38
  },
40
39
  "scripts": {
41
- "lint:eslint": "yarn ../.. eslint --report-unused-disable-directives --quiet @ornikar/eslint-config"
40
+ "lint:eslint": "ESLINT_USE_FLAT_CONFIG=false yarn ../.. eslint --report-unused-disable-directives --quiet @ornikar/eslint-config"
42
41
  }
43
42
  }
package/rollup.js CHANGED
@@ -1,13 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  // See https://github.com/ornikar/shared-configs/tree/master/%40ornikar/rollup-config
4
- module.exports = [
5
- {
6
- languageOptions: {
7
- globals: {
8
- __DEV__: 'writable',
9
- __TARGET__: 'writable',
10
- },
11
- },
4
+ module.exports = {
5
+ globals: {
6
+ __DEV__: true,
7
+ __TARGET__: true,
12
8
  },
13
- ];
9
+ };
package/root.js CHANGED
@@ -1,22 +1,19 @@
1
1
  'use strict';
2
2
 
3
- const nodeConfig = require('./node');
3
+ module.exports = {
4
+ extends: ['./node'].map(require.resolve),
4
5
 
5
- module.exports = [
6
- ...nodeConfig,
7
- {
8
- rules: {
9
- 'no-console': 'off',
10
- 'import/no-extraneous-dependencies': [
11
- 'error',
12
- {
13
- devDependencies: true,
14
- },
15
- ],
6
+ rules: {
7
+ 'no-console': 'off',
8
+ 'import/no-extraneous-dependencies': [
9
+ 'error',
10
+ {
11
+ devDependencies: true,
12
+ },
13
+ ],
16
14
 
17
- // Allow non-literal fs filename for dev scripts
18
- 'security/detect-non-literal-fs-filename': 'off',
19
- 'security/detect-non-literal-require': 'off',
20
- },
15
+ // Allow non-literal fs filename for dev scripts
16
+ 'security/detect-non-literal-fs-filename': 'off',
17
+ 'security/detect-non-literal-require': 'off',
21
18
  },
22
- ];
19
+ };
@@ -1,16 +1,14 @@
1
1
  'use strict';
2
2
 
3
- module.exports = [
4
- {
5
- rules: {
6
- // https://eslint.org/docs/rules/require-await
7
- 'require-await': 'error',
3
+ module.exports = {
4
+ rules: {
5
+ // https://eslint.org/docs/rules/require-await
6
+ 'require-await': 'error',
8
7
 
9
- // https://eslint.org/docs/rules/no-warning-comments
10
- 'no-warning-comments': ['error', { terms: ['fixme', 'xxx', 'console.'], location: 'start' }],
8
+ // https://eslint.org/docs/rules/no-warning-comments
9
+ 'no-warning-comments': ['error', { terms: ['fixme', 'xxx', 'console.'], location: 'start' }],
11
10
 
12
- // https://eslint.org/docs/rules/max-depth
13
- 'max-depth': ['warn', 6],
14
- },
11
+ // https://eslint.org/docs/rules/max-depth
12
+ 'max-depth': ['warn', 6],
15
13
  },
16
- ];
14
+ };
package/rules/imports.js CHANGED
@@ -1,15 +1,13 @@
1
1
  'use strict';
2
2
 
3
- module.exports = [
4
- {
5
- rules: {
6
- /* https://ornikar.atlassian.net/wiki/spaces/TECH/pages/2670330094/Avoid+default+export */
3
+ module.exports = {
4
+ rules: {
5
+ /* https://ornikar.atlassian.net/wiki/spaces/TECH/pages/2670330094/Avoid+default+export */
7
6
 
8
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
9
- 'import/prefer-default-export': 'off',
7
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
8
+ 'import/prefer-default-export': 'off',
10
9
 
11
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-default-export.md
12
- 'import/no-default-export': 'error',
13
- },
10
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-default-export.md
11
+ 'import/no-default-export': 'error',
14
12
  },
15
- ];
13
+ };
package/rules/jest.js CHANGED
@@ -1,16 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const jestPlugin = require('eslint-plugin-jest');
4
-
5
- module.exports = [
6
- {
7
- plugins: { jest: jestPlugin },
8
- // `eslint-plugin-jest` ships the Jest test globals (describe/it/expect/…) here.
9
- languageOptions: jestPlugin.configs['flat/recommended'].languageOptions,
10
- rules: {
11
- 'jest/no-disabled-tests': 'error',
12
- 'jest/no-focused-tests': 'error',
13
- 'jest/prefer-called-with': 'error',
14
- },
3
+ module.exports = {
4
+ plugins: ['jest'],
5
+ rules: {
6
+ 'jest/no-disabled-tests': 'error',
7
+ 'jest/no-focused-tests': 'error',
8
+ 'jest/prefer-called-with': 'error',
15
9
  },
16
- ];
10
+ };
@@ -2,33 +2,31 @@
2
2
 
3
3
  const airbnbStyleRules = require('eslint-config-airbnb-base/rules/style');
4
4
 
5
- module.exports = [
6
- {
7
- rules: {
8
- // already checked by import plugin
9
- 'n/no-unpublished-require': 'off',
10
- 'n/no-unpublished-import': 'off',
11
- 'n/no-extraneous-require': 'off',
12
- 'n/no-extraneous-import': 'off',
13
- 'n/no-missing-require': 'off',
14
- 'n/no-missing-import': 'off',
5
+ module.exports = {
6
+ rules: {
7
+ // already checked by import plugin
8
+ 'n/no-unpublished-require': 'off',
9
+ 'n/no-unpublished-import': 'off',
10
+ 'n/no-extraneous-require': 'off',
11
+ 'n/no-extraneous-import': 'off',
12
+ 'n/no-missing-require': 'off',
13
+ 'n/no-missing-import': 'off',
15
14
 
16
- // Use for-of instead of for
17
- 'unicorn/no-for-loop': 'error',
15
+ // Use for-of instead of for
16
+ 'unicorn/no-for-loop': 'error',
18
17
 
19
- // allow process.exit, disallowed when not used in script via https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-process-exit.md
20
- 'no-process-exit': 'off',
21
- 'n/no-process-exit': 'off',
18
+ // allow process.exit, disallowed when not used in script via https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-process-exit.md
19
+ 'no-process-exit': 'off',
20
+ 'n/no-process-exit': 'off',
22
21
 
23
- // Allow for-of, now supported by node 6
24
- 'no-restricted-syntax': [
25
- 'error',
26
- ...airbnbStyleRules.rules['no-restricted-syntax']
27
- .slice(1)
28
- .filter(({ selector }) => selector !== 'ForOfStatement'),
29
- ],
22
+ // Allow for-of, now supported by node 6
23
+ 'no-restricted-syntax': [
24
+ 'error',
25
+ ...airbnbStyleRules.rules['no-restricted-syntax']
26
+ .slice(1)
27
+ .filter(({ selector }) => selector !== 'ForOfStatement'),
28
+ ],
30
29
 
31
- 'unicorn/prefer-at': 'error',
32
- },
30
+ 'unicorn/prefer-at': 'error',
33
31
  },
34
- ];
32
+ };
package/rules/node.js CHANGED
@@ -1,34 +1,38 @@
1
1
  'use strict';
2
2
 
3
- const nPlugin = require('eslint-plugin-n');
4
- const nodeOverride = require('./node-override');
3
+ module.exports = {
4
+ plugins: ['n'],
5
+ extends: ['plugin:n/recommended', require.resolve('./node-override')],
5
6
 
6
- module.exports = [
7
- // `eslint-plugin-n`'s flat/recommended ships the Node globals and sourceType.
8
- nPlugin.configs['flat/recommended'],
9
- ...nodeOverride,
10
- {
11
- languageOptions: {
12
- // top level await is introduced in ecmaVersion: 2022 but supported since node 14
13
- ecmaVersion: 2022,
14
- },
7
+ parserOptions: {
8
+ // top level await is introduced in ecmaVersion: 2022 but supported since node 14
9
+ ecmaVersion: 2022,
15
10
  },
16
- {
17
- ...nPlugin.configs['flat/recommended-script'],
18
- files: ['**/*.cjs'],
11
+
12
+ env: {
13
+ browser: false,
14
+ node: true,
15
+ es6: true,
19
16
  },
20
- ...nodeOverride.map((entry) => ({ ...entry, files: ['**/*.cjs'] })),
21
- {
22
- ...nPlugin.configs['flat/recommended-module'],
23
- files: ['**/*.mjs'],
24
- languageOptions: {
25
- ...nPlugin.configs['flat/recommended-module'].languageOptions,
26
- ecmaVersion: 2022,
17
+
18
+ overrides: [
19
+ {
20
+ files: ['*.cjs'],
21
+ extends: ['plugin:n/recommended-script', require.resolve('./node-override')],
27
22
  },
28
- },
29
- ...nodeOverride.map((entry) => ({ ...entry, files: ['**/*.mjs'] })),
30
- {
31
- files: ['**/scripts/**'],
32
- rules: { 'n/hashbang': 'off' },
33
- },
34
- ];
23
+ {
24
+ files: ['*.mjs'],
25
+ extends: ['plugin:n/recommended-module', require.resolve('./node-override')],
26
+ parserOptions: {
27
+ // top level await is introduced in ecmaVersion: 2022 but supported since node 14
28
+ ecmaVersion: 2022,
29
+ },
30
+ },
31
+ {
32
+ files: ['scripts/**'],
33
+ rules: {
34
+ 'n/hashbang': 'off',
35
+ },
36
+ },
37
+ ],
38
+ };
package/rules/ornikar.js CHANGED
@@ -1,10 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const ornikarPlugin = require('@ornikar/eslint-plugin-ornikar');
4
-
5
- module.exports = [
6
- {
7
- plugins: { '@ornikar/ornikar': ornikarPlugin },
8
- rules: ornikarPlugin.configs.recommended.rules,
9
- },
10
- ];
3
+ module.exports = {
4
+ plugins: ['@ornikar/ornikar'],
5
+ extends: ['plugin:@ornikar/ornikar/recommended'],
6
+ };
package/rules/prettier.js CHANGED
@@ -1,18 +1,15 @@
1
1
  'use strict';
2
2
 
3
- const prettierConfig = require('eslint-config-prettier');
3
+ module.exports = {
4
+ extends: ['eslint-config-prettier'].map(require.resolve),
4
5
 
5
- module.exports = [
6
- prettierConfig,
7
- {
8
- rules: {
9
- // https://github.com/prettier/eslint-config-prettier#curly
10
- // prettier doesn't enforce {} with multiline
11
- curly: ['error', 'multi-line'],
6
+ rules: {
7
+ // https://github.com/prettier/eslint-config-prettier#curly
8
+ // prettier doesn't enforce {} with multiline
9
+ curly: ['error', 'multi-line'],
12
10
 
13
- // https://github.com/prettier/eslint-config-prettier#quotes
14
- // prettier doesn't change backtick to single
15
- quotes: ['error', 'single', { avoidEscape: true }],
16
- },
11
+ // https://github.com/prettier/eslint-config-prettier#quotes
12
+ // prettier doesn't change backtick to single
13
+ quotes: ['error', 'single', { avoidEscape: true }],
17
14
  },
18
- ];
15
+ };