@o3r/eslint-config 12.3.0-prerelease.3 → 12.3.0-prerelease.31
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 +14 -11
- package/schematics/ng-add/eslint/templates/project/eslint.config.__extension__.template +8 -4
- package/schematics/ng-add/eslint/templates/project/eslint.local.config.__extension__.template +14 -9
- package/schematics/ng-add/eslint/templates/workspace/eslint.config.__extension__.template +5 -51
- package/schematics/ng-add/eslint/templates/workspace/eslint.local.config.__extension__.template +13 -5
- package/schematics/ng-add/eslint/templates/workspace/eslint.shared.config.__extension__.template +21 -8
- package/src/helpers/index.cjs +55 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/eslint-config",
|
|
3
|
-
"version": "12.3.0-prerelease.
|
|
3
|
+
"version": "12.3.0-prerelease.31",
|
|
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.
|
|
43
|
-
"@o3r/eslint-plugin": "^12.3.0-prerelease.
|
|
44
|
-
"@o3r/schematics": "^12.3.0-prerelease.
|
|
45
|
+
"@eslint/js": "^8.57.0 || ^9.22.0",
|
|
46
|
+
"@o3r/eslint-plugin": "^12.3.0-prerelease.31",
|
|
47
|
+
"@o3r/schematics": "^12.3.0-prerelease.31",
|
|
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.
|
|
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.
|
|
77
|
+
"@eslint/js": "~9.24.0",
|
|
75
78
|
"@nx/eslint-plugin": "~20.7.0",
|
|
76
|
-
"@o3r/build-helpers": "^12.3.0-prerelease.
|
|
77
|
-
"@o3r/eslint-plugin": "^12.3.0-prerelease.
|
|
78
|
-
"@o3r/schematics": "^12.3.0-prerelease.
|
|
79
|
-
"@o3r/test-helpers": "^12.3.0-prerelease.
|
|
79
|
+
"@o3r/build-helpers": "^12.3.0-prerelease.31",
|
|
80
|
+
"@o3r/eslint-plugin": "^12.3.0-prerelease.31",
|
|
81
|
+
"@o3r/schematics": "^12.3.0-prerelease.31",
|
|
82
|
+
"@o3r/test-helpers": "^12.3.0-prerelease.31",
|
|
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.
|
|
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
|
|
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
|
|
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
|
+
]);
|
package/schematics/ng-add/eslint/templates/project/eslint.local.config.__extension__.template
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
<% if (extension === 'mjs') { %>import {
|
|
2
|
-
|
|
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
|
|
16
|
+
<% } else { %>const { defineConfig } = require('eslint/config');
|
|
17
|
+
<% if (isApp) { %>const globals = require('globals');
|
|
10
18
|
<% } %>
|
|
11
|
-
|
|
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 {
|
|
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);
|
package/schematics/ng-add/eslint/templates/workspace/eslint.local.config.__extension__.template
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
<% if (extension === 'mjs') { %>import {
|
|
2
|
-
|
|
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
|
-
<% }
|
|
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 %>
|
package/schematics/ng-add/eslint/templates/workspace/eslint.shared.config.__extension__.template
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
<% if (extension === 'mjs') { %>
|
|
2
|
-
import {
|
|
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
|
-
|
|
24
|
-
|
|
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
|
+
]);
|
|
@@ -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
|
+
};
|