@o3r/eslint-config 12.3.0-prerelease.4 → 12.3.0-prerelease.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/eslint-config",
3
- "version": "12.3.0-prerelease.4",
3
+ "version": "12.3.0-prerelease.40",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -13,6 +13,9 @@
13
13
  ".": {
14
14
  "default": "./src/rules/typescript.cjs"
15
15
  },
16
+ "./helpers": {
17
+ "default": "./src/helpers/index.cjs"
18
+ },
16
19
  "./typescript": {
17
20
  "default": "./src/rules/typescript.cjs"
18
21
  },
@@ -39,16 +42,16 @@
39
42
  "@angular-eslint/builder": "^19.0.0",
40
43
  "@angular/compiler": "^19.0.0",
41
44
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
42
- "@eslint/js": "^8.57.0 || ^9.16.0",
43
- "@o3r/eslint-plugin": "^12.3.0-prerelease.4",
44
- "@o3r/schematics": "^12.3.0-prerelease.4",
45
+ "@eslint/js": "^8.57.0 || ^9.22.0",
46
+ "@o3r/eslint-plugin": "^12.3.0-prerelease.40",
47
+ "@o3r/schematics": "^12.3.0-prerelease.40",
45
48
  "@schematics/angular": "^19.0.0",
46
49
  "@stylistic/eslint-plugin": "~3.1.0",
47
50
  "@typescript-eslint/parser": "^8.15.0",
48
51
  "@typescript-eslint/types": "^8.15.0",
49
52
  "@typescript-eslint/utils": "^8.15.0",
50
53
  "angular-eslint": "^19.0.0",
51
- "eslint": "^8.57.0 || ^9.16.0",
54
+ "eslint": "^8.57.0 || ^9.22.0",
52
55
  "eslint-import-resolver-node": "^0.3.4",
53
56
  "eslint-import-resolver-typescript": "^3.6.3",
54
57
  "eslint-plugin-import": "^2.31.0",
@@ -71,12 +74,12 @@
71
74
  "@angular-devkit/schematics": "~19.2.0",
72
75
  "@angular/compiler": "~19.2.0",
73
76
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
74
- "@eslint/js": "~9.23.0",
77
+ "@eslint/js": "~9.24.0",
75
78
  "@nx/eslint-plugin": "~20.7.0",
76
- "@o3r/build-helpers": "^12.3.0-prerelease.4",
77
- "@o3r/eslint-plugin": "^12.3.0-prerelease.4",
78
- "@o3r/schematics": "^12.3.0-prerelease.4",
79
- "@o3r/test-helpers": "^12.3.0-prerelease.4",
79
+ "@o3r/build-helpers": "^12.3.0-prerelease.40",
80
+ "@o3r/eslint-plugin": "^12.3.0-prerelease.40",
81
+ "@o3r/schematics": "^12.3.0-prerelease.40",
82
+ "@o3r/test-helpers": "^12.3.0-prerelease.40",
80
83
  "@schematics/angular": "~19.2.0",
81
84
  "@stylistic/eslint-plugin": "~3.1.0",
82
85
  "@types/eslint__js": "^8.42.3",
@@ -85,7 +88,7 @@
85
88
  "@typescript-eslint/parser": "~8.29.0",
86
89
  "angular-eslint": "~19.3.0",
87
90
  "cpy-cli": "^5.0.0",
88
- "eslint": "~9.23.0",
91
+ "eslint": "~9.24.0",
89
92
  "eslint-import-resolver-node": "~0.3.9",
90
93
  "eslint-import-resolver-typescript": "~3.10.0",
91
94
  "eslint-plugin-import": "~2.31.0",
@@ -1,10 +1,14 @@
1
- <% if (extension === 'mjs') { %>import local from './eslint.local.config.mjs';
1
+ <% if (extension === 'mjs') { %>import {
2
+ defineConfig,
3
+ } from 'eslint/config';
4
+ import local from './eslint.local.config.mjs';
2
5
  import shared from '<%= relativePathToRoot %>/eslint.shared.config.mjs';
3
- <% } else { %>const local = require('./eslint.local.config.<%= extension %>');
6
+ <% } else { %>const { defineConfig } = require('eslint/config');
7
+ const local = require('./eslint.local.config.<%= extension %>');
4
8
  const shared = require('<%= relativePathToRoot %>/eslint.shared.config.<%= extension %>');
5
9
  <% } %>
6
10
 
7
- <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> [
11
+ <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> defineConfig([
8
12
  ...shared,
9
13
  ...local
10
- ];
14
+ ]);
@@ -1,14 +1,23 @@
1
- <% if (extension === 'mjs') { %>import { dirname } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
1
+ <% if (extension === 'mjs') { %>import {
2
+ defineConfig,
3
+ } from 'eslint/config';
4
+ import {
5
+ dirname,
6
+ } from 'node:path';
7
+ import {
8
+ fileURLToPath,
9
+ } from 'node:url';
3
10
  <% if (isApp) {
4
11
  %>import globals from 'globals';<%
5
12
  } %>
6
13
  const __filename = fileURLToPath(import.meta.url);
7
14
  // __dirname is not defined in ES module scope
8
15
  const __dirname = dirname(__filename);
9
- <% } else if (isApp) { %>const globals = require('globals');
16
+ <% } else { %>const { defineConfig } = require('eslint/config');
17
+ <% if (isApp) { %>const globals = require('globals');
10
18
  <% } %>
11
- <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> [
19
+ <% } %>
20
+ <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> defineConfig([
12
21
  {
13
22
  name: '<%= packageName %>/projects',
14
23
  languageOptions: {
@@ -23,9 +32,5 @@ const __dirname = dirname(__filename);
23
32
  ...globals.browser
24
33
  }<% } %>
25
34
  }
26
- },
27
- {
28
- name: '<%= packageName %>/ignores',
29
- ignores: []
30
35
  }
31
- ];
36
+ ]);
@@ -1,66 +1,20 @@
1
1
  <% if (extension === 'mjs') { %>import {
2
+ mergeESLintFlatConfigs,
3
+ } from '@o3r/eslint-config';
4
+ import {
2
5
  dirname,
3
- posix,
4
- relative,
5
- sep
6
6
  } from 'node:path';
7
7
  import {
8
8
  fileURLToPath,
9
- pathToFileURL
10
9
  } from 'node:url';
11
10
  import shared from './eslint.shared.config.mjs';
12
- import {
13
- sync
14
- } from 'globby';
15
11
 
16
12
  const __filename = fileURLToPath(import.meta.url);
17
13
  // __dirname is not defined in ES module scope
18
14
  const __dirname = dirname(__filename);
19
15
  <% } else { %>
20
- const { dirname, posix, relative, sep } = require('node:path');
21
- const { sync } = require('globby');
16
+ const { mergeESLintFlatConfigs } = require('@o3r/eslint-config/helpers');
22
17
  const shared = require('./eslint.shared.config.<%= extension %>');
23
18
  <% } %>
24
19
 
25
- /**
26
- * Add a prefix to a path glob
27
- * @param {string} prefix
28
- * @param {string | undefined} pathGlob
29
- * @returns {string}
30
- */
31
- const addPrefix = (prefix, pathGlob = '**/*') => pathGlob.replace(/^(!?)(\.?\/)?/, `$1${prefix}/`).replaceAll(sep, posix.sep).replace(/^\//, '');
32
-
33
- /**
34
- * Merge ESLint config
35
- * @param {string | string[]} globs List of globs to find ESLint config path
36
- * @returns {Promise<import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray>}
37
- */
38
- const mergeESLintConfigs = async (globs) => {
39
- const localConfigFiles = sync(globs, { absolute: true });
40
- /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
41
- let localConfigs = [];
42
- for (const localConfigFile of localConfigFiles) {
43
- const module = await import(pathToFileURL(localConfigFile));
44
- const moduleConfig = await (module.default ?? module);
45
- /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
46
- const configArray = Array.isArray(moduleConfig) ? moduleConfig : [moduleConfig];
47
- const directory = relative(__dirname, dirname(localConfigFile));
48
- localConfigs = localConfigs.concat(
49
- configArray.map((config) => ({
50
- ...config,
51
- ...(
52
- config.ignores
53
- ? { ignores: config.ignores.map((pathGlob) => addPrefix(directory, pathGlob)) }
54
- : { files: (config.files || ['**/*']).flat().map((pathGlob) => addPrefix(directory, pathGlob)) }
55
- )
56
- }))
57
- );
58
- }
59
-
60
- return [
61
- ...shared,
62
- ...localConfigs
63
- ];
64
- };
65
-
66
- <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> mergeESLintConfigs('**/eslint.local.config.mjs');
20
+ <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> mergeESLintFlatConfigs(__dirname, '**/eslint.local.config.mjs', shared);
@@ -1,11 +1,19 @@
1
- <% if (extension === 'mjs') { %>import { dirname } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
1
+ <% if (extension === 'mjs') { %>import {
2
+ defineConfig,
3
+ } from 'eslint/config';
4
+ import {
5
+ dirname,
6
+ } from 'node:path';
7
+ import {
8
+ fileURLToPath,
9
+ } from 'node:url';
3
10
 
4
11
  const __filename = fileURLToPath(import.meta.url);
5
12
  // __dirname is not defined in ES module scope
6
13
  const __dirname = dirname(__filename);
7
-
8
- <% } %><%= codeBeforeConfig %><%= extension === 'mjs' ? 'export default' : 'module.exports =' %> [
14
+ <% } else { %>const { defineConfig } = require('eslint/config');
15
+ <% } %>
16
+ <%= codeBeforeConfig %><%= extension === 'mjs' ? 'export default' : 'module.exports =' %> defineConfig([
9
17
  {
10
18
  name: '<%= packageName %>/projects',
11
19
  languageOptions: {
@@ -18,5 +26,5 @@ const __dirname = dirname(__filename);
18
26
  }
19
27
  }
20
28
  }
21
- ].concat(<%= oldConfig %>);
29
+ ].concat(<%= oldConfig %>));
22
30
  <%= codeAfterConfig %>
@@ -1,5 +1,15 @@
1
- <% if (extension === 'mjs') { %>import { dirname, join } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
1
+ <% if (extension === 'mjs') { %>
2
+ import {
3
+ defineConfig,
4
+ globalIgnores,
5
+ } from 'eslint/config';
6
+ import {
7
+ dirname,
8
+ join,
9
+ } from 'node:path';
10
+ import {
11
+ fileURLToPath,
12
+ } from 'node:url';
3
13
  import o3rConfig from '@o3r/eslint-config';
4
14
  import o3rTemplate from '@o3r/eslint-config/template';
5
15
 
@@ -8,9 +18,10 @@ const __filename = fileURLToPath(import.meta.url);
8
18
  const __dirname = dirname(__filename);
9
19
  <% } else { %>const o3rConfig = require('@o3r/eslint-config');
10
20
  const o3rTemplate = require('@o3r/eslint-config/template');
21
+ const { defineConfig, globalIgnores } = require('eslint/config');
11
22
  <% } %>
12
23
 
13
- <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> [
24
+ <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> defineConfig([
14
25
  ...o3rConfig,
15
26
  ...o3rTemplate,
16
27
  {
@@ -19,10 +30,12 @@ const o3rTemplate = require('@o3r/eslint-config/template');
19
30
  reportUnusedDisableDirectives: 'error'
20
31
  }
21
32
  },
22
- {
23
- name: '<%= packageName %>/ignores',
24
- ignores: []
25
- },
33
+ globalIgnores(
34
+ [
35
+ '**/dist/'
36
+ ],
37
+ '<%= packageName %>/ignores'
38
+ ),
26
39
  {
27
40
  name: '<%= packageName %>/settings',
28
41
  settings: {
@@ -48,4 +61,4 @@ const o3rTemplate = require('@o3r/eslint-config/template');
48
61
  ]
49
62
  }
50
63
  }<% } %>
51
- ];
64
+ ]);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAgIlB;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,qBAAqB,KAAG,IAKtD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAOpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAiIlB;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,qBAAqB,KAAG,IAKtD,CAAC"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ngAdd = void 0;
4
4
  const path = require("node:path");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const schematics_2 = require("@o3r/schematics");
6
7
  const index_1 = require("./eslint/index");
7
8
  const index_2 = require("./vscode/index");
8
9
  const reportMissingSchematicsDep = (logger) => (reason) => {
@@ -111,7 +112,8 @@ function ngAddFn(options) {
111
112
  (0, index_1.updateEslintConfig)(__dirname, options.projectName),
112
113
  options.fix ? handleOtterEslintErrors(options.projectName) : (0, schematics_1.noop)()
113
114
  ])
114
- : (0, schematics_1.noop)()
115
+ : (0, schematics_1.noop)(),
116
+ options.skipLinter ? (0, schematics_1.noop)() : (0, schematics_2.applyEditorConfig)()
115
117
  ])(tree, context);
116
118
  };
117
119
  }
@@ -6,5 +6,7 @@ export interface NgAddSchematicsSchema extends SchematicOptionObject {
6
6
  exactO3rVersion?: boolean;
7
7
  /** Fix known issues with our ESLint config after Otter application or library generation */
8
8
  fix?: boolean;
9
+ /** Skip the linter process which includes EditorConfig rules applying */
10
+ skipLinter: boolean;
9
11
  }
10
12
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,8CAA8C;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,4FAA4F;IAC5F,GAAG,CAAC,EAAE,OAAO,CAAC;CACf"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,8CAA8C;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,4FAA4F;IAC5F,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,yEAAyE;IACzE,UAAU,EAAE,OAAO,CAAC;CACrB"}
@@ -18,6 +18,11 @@
18
18
  "fix": {
19
19
  "type": "boolean",
20
20
  "description": "Fix known issues with our ESLint config after Otter application or library generation"
21
+ },
22
+ "skipLinter": {
23
+ "type": "boolean",
24
+ "description": "Skip the linter process which includes EditorConfig rules applying",
25
+ "default": false
21
26
  }
22
27
  },
23
28
  "additionalProperties": true,
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+ const { dirname, posix, relative, sep } = require('node:path');
3
+ const { pathToFileURL } = require('node:url');
4
+ const { defineConfig } = require('eslint/config');
5
+ const { sync } = require('globby');
6
+
7
+ /**
8
+ * Add a prefix to a path glob
9
+ * @param {string} prefix
10
+ * @param {string | undefined} pathGlob
11
+ * @returns {string}
12
+ */
13
+ const addPrefix = (prefix, pathGlob = '**/*') => pathGlob.replace(/^(!?)(\.?\/)?/, `$1${prefix}/`).replaceAll(sep, posix.sep).replace(/^\//, '');
14
+
15
+ /**
16
+ * Merge ESLint flat config
17
+ * @param {string} localDirname The directory name of the current module
18
+ * @param {string | string[]} globs List of globs to find ESLint config path
19
+ * @param {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray[]} additionalConfigs List of additional config to apply first
20
+ * @returns {Promise<import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray>}
21
+ */
22
+ const mergeESLintFlatConfigs = async (localDirname, globs, ...additionalConfigs) => {
23
+ const localConfigFiles = sync(globs, { absolute: true });
24
+ /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
25
+ let configs = [];
26
+ for (const localConfigFile of localConfigFiles) {
27
+ const module = await import(pathToFileURL(localConfigFile));
28
+ const moduleConfig = await (module.default ?? module);
29
+ /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
30
+ const configArray = Array.isArray(moduleConfig) ? moduleConfig : [moduleConfig];
31
+ const directory = relative(localDirname, dirname(localConfigFile));
32
+ configs = configs.concat(
33
+ configArray.map((config) => ({
34
+ ...config,
35
+ ...(
36
+ config.ignores
37
+ ? {
38
+ ignores: config.ignores.map((pathGlob) => addPrefix(directory, pathGlob)),
39
+ ...config.files && config.files.flat().map((pathGlob) => addPrefix(directory, pathGlob))
40
+ }
41
+ : { files: (config.files || ['**/*']).flat().map((pathGlob) => addPrefix(directory, pathGlob)) }
42
+ )
43
+ }))
44
+ );
45
+ }
46
+
47
+ return defineConfig([
48
+ ...additionalConfigs,
49
+ ...configs
50
+ ]);
51
+ };
52
+
53
+ module.exports = {
54
+ mergeESLintFlatConfigs
55
+ };