@ornikar/eslint-config 22.7.3 → 22.7.4

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## <small>22.7.4 (2026-05-28)</small>
7
+
8
+ * feat!: ESLint flat-config migration [OSE-20589] (#820) ([6c7897b](https://github.com/ornikar/eslint-configs/commit/6c7897b)), closes [#820](https://github.com/ornikar/eslint-configs/issues/820)
9
+
10
+
11
+
12
+
13
+
6
14
  ## <small>22.7.3 (2026-05-26)</small>
7
15
 
8
16
  * feat!: ESLint v9 engine bump (legacy .eslintrc preserved) [OSE-20589] (#818) ([9683864](https://github.com/ornikar/eslint-configs/commit/9683864)), closes [#818](https://github.com/ornikar/eslint-configs/issues/818)
package/README.md CHANGED
@@ -15,76 +15,105 @@ 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
+
18
20
  ### root
19
21
 
20
22
  1. `npm install --save-dev eslint @ornikar/eslint-config`
21
- 2. Add `"extends": ["@ornikar/eslint-config/root"]` to your 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
+ ```
22
30
 
23
31
  ### node without babel or typescript
24
32
 
25
33
  1. `npm install --save-dev eslint @ornikar/eslint-config`
26
- 2. Add `"extends": ["@ornikar/eslint-config", "@ornikar/eslint-config/node"]` to your 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
+ ```
27
41
 
28
42
  ### node with babel (deprecated, please use typescript instead)
29
43
 
30
44
  1. `npm install --save-dev eslint @ornikar/eslint-config @ornikar/eslint-config-babel`
31
- 2. Add `"extends": ["@ornikar/eslint-config-babel", "@ornikar/eslint-config/node""]` to your eslint config
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
+ ```
32
52
 
33
53
  ### node with typescript
34
54
 
35
55
  1. `npm install --save-dev eslint @ornikar/eslint-config @ornikar/eslint-config-typescript`
36
- 2. Add `"extends": ["@ornikar/eslint-config-typescript", "@ornikar/eslint-config/node"]` to your eslint config
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
+ ```
37
63
 
38
64
  ### module override
39
65
 
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
- }
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
+ ]);
51
80
  ```
52
81
 
53
82
  ## How to configure a project
54
83
 
55
- ### Two configurations files
84
+ ### Two configuration files
56
85
 
57
- In a project you should have two configurations files:
86
+ In a project you should have two configuration files:
58
87
 
59
- - /.eslintrc.json
60
- - /{src,lib}/.eslintrc.json
88
+ - /eslint.config.js
89
+ - /{src,lib}/eslint.config.js
61
90
 
62
91
  If the project is compiled, use `src` for source and `dist` for compilation with rollup.
63
92
  If the project is not compiled, use `lib`.
64
- If the project is CRA, next or build with webpack, use `src` for source and `build` or the build directory your tool uses.
93
+ If the project is CRA, next or built with webpack, use `src` for source and `build` or the build directory your tool uses.
65
94
 
66
95
  Using two config files is important:
67
96
 
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.
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
70
99
 
71
- ### Use `"root": true`
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.
72
101
 
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.
102
+ ### Use `ignores`
74
103
 
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 !
104
+ Replace `.eslintignore` with the `ignores` property in your flat config:
76
105
 
77
- ### Use `ignorePatterns` in .eslintrc.json
78
-
79
- Use `ignorePatterns` instead of .eslintignore file. We have enough configuration files !
106
+ ```js
107
+ module.exports = [{ ignores: ['dist/**', 'coverage/**'] }, ...ornikarRoot];
108
+ ```
80
109
 
81
110
  ### Use `--report-unused-disable-directives`
82
111
 
83
- Really usefull tip, it prevents leaving unused eslint-disable directives.
112
+ Really useful tip it prevents leaving unused eslint-disable directives.
84
113
 
85
- ### Lerna/Workspaces Configuration
114
+ ### Lerna/Workspaces configuration
86
115
 
87
- Assuming your package.json looks like `"workspaces": ["packages/*"]`:
116
+ Assuming your `package.json` has `"workspaces": ["packages/*"]`:
88
117
 
89
- - /.eslintrc.json
90
- - /packages/\*/{src,lib}/.eslintrc.json
118
+ - /eslint.config.js
119
+ - /packages/\*/{src,lib}/eslint.config.js
package/_shared.js CHANGED
@@ -1,13 +1,11 @@
1
1
  'use strict';
2
2
 
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
- };
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];
package/graphql.js CHANGED
@@ -1,13 +1,15 @@
1
1
  'use strict';
2
2
 
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
- ],
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
+ },
12
14
  },
13
- };
15
+ ];
package/index.js CHANGED
@@ -1,21 +1,29 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- extends: ['eslint-config-airbnb-base', './_shared', './rules/prettier'].map(require.resolve),
3
+ const { FlatCompat } = require('@eslint/eslintrc');
4
+ const sharedConfig = require('./_shared');
5
+ const prettierConfig = require('./rules/prettier');
5
6
 
6
- parserOptions: {
7
- sourceType: 'script',
8
- ecmaVersion: 2021,
9
- },
7
+ const compat = new FlatCompat({ baseDirectory: __dirname });
10
8
 
11
- rules: {
12
- strict: ['error', 'safe'],
13
- 'import/extensions': [
14
- 'error',
15
- 'ignorePackages',
16
- {
17
- js: 'never',
18
- },
19
- ],
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
+ },
20
28
  },
21
- };
29
+ ];
@@ -1,10 +1,16 @@
1
1
  'use strict';
2
2
 
3
+ const nPlugin = require('eslint-plugin-n');
4
+ const nodeOverride = require('./rules/node-override');
5
+
3
6
  /* prefer usage of .mjs files over this override */
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,
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
+ },
9
15
  },
10
- };
16
+ ];
package/node.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- extends: ['.', './rules/node', './rules/prettier'].map(require.resolve),
5
- };
3
+ const nodeRules = require('./rules/node');
4
+ const prettierConfig = require('./rules/prettier');
5
+ const indexConfig = require('.');
6
+
7
+ module.exports = [...indexConfig, ...nodeRules, ...prettierConfig];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornikar/eslint-config",
3
- "version": "22.7.3",
3
+ "version": "22.7.4",
4
4
  "description": "eslint config files",
5
5
  "repository": {
6
6
  "directory": "@ornikar/eslint-config",
@@ -16,7 +16,8 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@ornikar/eslint-plugin-ornikar": "22.7.3",
19
+ "@eslint/eslintrc": "^3.3.5",
20
+ "@ornikar/eslint-plugin-ornikar": "22.7.4",
20
21
  "eslint-config-airbnb-base": "^15.0.0",
21
22
  "eslint-config-prettier": "^10.0.0",
22
23
  "eslint-import-resolver-typescript": "^4.4.4",
@@ -37,6 +38,6 @@
37
38
  "prettier": "2.8.8"
38
39
  },
39
40
  "scripts": {
40
- "lint:eslint": "ESLINT_USE_FLAT_CONFIG=false yarn ../.. eslint --report-unused-disable-directives --quiet @ornikar/eslint-config"
41
+ "lint:eslint": "yarn ../.. eslint --report-unused-disable-directives --quiet @ornikar/eslint-config"
41
42
  }
42
43
  }
package/rollup.js CHANGED
@@ -1,9 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  // See https://github.com/ornikar/shared-configs/tree/master/%40ornikar/rollup-config
4
- module.exports = {
5
- globals: {
6
- __DEV__: true,
7
- __TARGET__: true,
4
+ module.exports = [
5
+ {
6
+ languageOptions: {
7
+ globals: {
8
+ __DEV__: 'writable',
9
+ __TARGET__: 'writable',
10
+ },
11
+ },
8
12
  },
9
- };
13
+ ];
package/root.js CHANGED
@@ -1,19 +1,22 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- extends: ['./node'].map(require.resolve),
3
+ const nodeConfig = require('./node');
5
4
 
6
- rules: {
7
- 'no-console': 'off',
8
- 'import/no-extraneous-dependencies': [
9
- 'error',
10
- {
11
- devDependencies: true,
12
- },
13
- ],
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
+ ],
14
16
 
15
- // Allow non-literal fs filename for dev scripts
16
- 'security/detect-non-literal-fs-filename': 'off',
17
- 'security/detect-non-literal-require': 'off',
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
+ },
18
21
  },
19
- };
22
+ ];
@@ -1,14 +1,16 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- rules: {
5
- // https://eslint.org/docs/rules/require-await
6
- 'require-await': 'error',
3
+ module.exports = [
4
+ {
5
+ rules: {
6
+ // https://eslint.org/docs/rules/require-await
7
+ 'require-await': 'error',
7
8
 
8
- // https://eslint.org/docs/rules/no-warning-comments
9
- 'no-warning-comments': ['error', { terms: ['fixme', 'xxx', 'console.'], location: 'start' }],
9
+ // https://eslint.org/docs/rules/no-warning-comments
10
+ 'no-warning-comments': ['error', { terms: ['fixme', 'xxx', 'console.'], location: 'start' }],
10
11
 
11
- // https://eslint.org/docs/rules/max-depth
12
- 'max-depth': ['warn', 6],
12
+ // https://eslint.org/docs/rules/max-depth
13
+ 'max-depth': ['warn', 6],
14
+ },
13
15
  },
14
- };
16
+ ];
package/rules/imports.js CHANGED
@@ -1,13 +1,15 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- rules: {
5
- /* https://ornikar.atlassian.net/wiki/spaces/TECH/pages/2670330094/Avoid+default+export */
3
+ module.exports = [
4
+ {
5
+ rules: {
6
+ /* https://ornikar.atlassian.net/wiki/spaces/TECH/pages/2670330094/Avoid+default+export */
6
7
 
7
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
8
- 'import/prefer-default-export': 'off',
8
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
9
+ 'import/prefer-default-export': 'off',
9
10
 
10
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-default-export.md
11
- 'import/no-default-export': 'error',
11
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-default-export.md
12
+ 'import/no-default-export': 'error',
13
+ },
12
14
  },
13
- };
15
+ ];
package/rules/jest.js CHANGED
@@ -1,10 +1,16 @@
1
1
  'use strict';
2
2
 
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',
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
+ },
9
15
  },
10
- };
16
+ ];
@@ -2,31 +2,33 @@
2
2
 
3
3
  const airbnbStyleRules = require('eslint-config-airbnb-base/rules/style');
4
4
 
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',
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',
14
15
 
15
- // Use for-of instead of for
16
- 'unicorn/no-for-loop': 'error',
16
+ // Use for-of instead of for
17
+ 'unicorn/no-for-loop': 'error',
17
18
 
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',
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',
21
22
 
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
- ],
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
+ ],
29
30
 
30
- 'unicorn/prefer-at': 'error',
31
+ 'unicorn/prefer-at': 'error',
32
+ },
31
33
  },
32
- };
34
+ ];
package/rules/node.js CHANGED
@@ -1,38 +1,34 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- plugins: ['n'],
5
- extends: ['plugin:n/recommended', require.resolve('./node-override')],
3
+ const nPlugin = require('eslint-plugin-n');
4
+ const nodeOverride = require('./node-override');
6
5
 
7
- parserOptions: {
8
- // top level await is introduced in ecmaVersion: 2022 but supported since node 14
9
- ecmaVersion: 2022,
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
+ },
10
15
  },
11
-
12
- env: {
13
- browser: false,
14
- node: true,
15
- es6: true,
16
+ {
17
+ ...nPlugin.configs['flat/recommended-script'],
18
+ files: ['**/*.cjs'],
16
19
  },
17
-
18
- overrides: [
19
- {
20
- files: ['*.cjs'],
21
- extends: ['plugin:n/recommended-script', require.resolve('./node-override')],
22
- },
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
- },
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,
30
27
  },
31
- {
32
- files: ['scripts/**'],
33
- rules: {
34
- 'n/hashbang': 'off',
35
- },
36
- },
37
- ],
38
- };
28
+ },
29
+ ...nodeOverride.map((entry) => ({ ...entry, files: ['**/*.mjs'] })),
30
+ {
31
+ files: ['**/scripts/**'],
32
+ rules: { 'n/hashbang': 'off' },
33
+ },
34
+ ];
package/rules/ornikar.js CHANGED
@@ -1,6 +1,10 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- plugins: ['@ornikar/ornikar'],
5
- extends: ['plugin:@ornikar/ornikar/recommended'],
6
- };
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
+ ];
package/rules/prettier.js CHANGED
@@ -1,15 +1,18 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- extends: ['eslint-config-prettier'].map(require.resolve),
3
+ const prettierConfig = require('eslint-config-prettier');
5
4
 
6
- rules: {
7
- // https://github.com/prettier/eslint-config-prettier#curly
8
- // prettier doesn't enforce {} with multiline
9
- curly: ['error', 'multi-line'],
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'],
10
12
 
11
- // https://github.com/prettier/eslint-config-prettier#quotes
12
- // prettier doesn't change backtick to single
13
- quotes: ['error', 'single', { avoidEscape: true }],
13
+ // https://github.com/prettier/eslint-config-prettier#quotes
14
+ // prettier doesn't change backtick to single
15
+ quotes: ['error', 'single', { avoidEscape: true }],
16
+ },
14
17
  },
15
- };
18
+ ];