@o3r/eslint-config 12.3.0-prerelease.9 → 12.3.0-rc.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/package.json +21 -16
- package/schematics/ng-add/eslint/index.d.ts.map +1 -1
- package/schematics/ng-add/eslint/index.js +8 -9
- package/schematics/ng-add/eslint/index.js.map +1 -0
- 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 +16 -12
- 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 +14 -7
- package/schematics/ng-add/eslint/templates/workspace/eslint.shared.config.__extension__.template +22 -11
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +12 -20
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.d.ts +2 -0
- package/schematics/ng-add/schema.d.ts.map +1 -1
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +5 -0
- package/schematics/ng-add/tsconfig/index.d.ts.map +1 -1
- package/schematics/ng-add/tsconfig/index.js +3 -3
- package/schematics/ng-add/tsconfig/index.js.map +1 -0
- package/schematics/ng-add/vscode/index.d.ts.map +1 -1
- package/schematics/ng-add/vscode/index.js +3 -3
- package/schematics/ng-add/vscode/index.js.map +1 -0
- 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-
|
|
3
|
+
"version": "12.3.0-rc.0",
|
|
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
|
},
|
|
@@ -33,22 +36,25 @@
|
|
|
33
36
|
"prepare:build:builders": "yarn cpy 'schematics/**/*.json' 'schematics/**/templates/**' dist/schematics && yarn cpy 'collection.json' dist",
|
|
34
37
|
"build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
|
|
35
38
|
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@o3r/schematics": "^12.3.0-rc.0"
|
|
41
|
+
},
|
|
36
42
|
"peerDependencies": {
|
|
37
43
|
"@angular-devkit/core": "^19.0.0",
|
|
38
44
|
"@angular-devkit/schematics": "^19.0.0",
|
|
39
45
|
"@angular-eslint/builder": "^19.0.0",
|
|
40
46
|
"@angular/compiler": "^19.0.0",
|
|
41
47
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
42
|
-
"@eslint/js": "^8.57.0 || ^9.
|
|
43
|
-
"@o3r/eslint-plugin": "^12.3.0-
|
|
44
|
-
"@o3r/schematics": "^12.3.0-
|
|
48
|
+
"@eslint/js": "^8.57.0 || ^9.22.0",
|
|
49
|
+
"@o3r/eslint-plugin": "^12.3.0-rc.0",
|
|
50
|
+
"@o3r/schematics": "^12.3.0-rc.0",
|
|
45
51
|
"@schematics/angular": "^19.0.0",
|
|
46
52
|
"@stylistic/eslint-plugin": "~3.1.0",
|
|
47
53
|
"@typescript-eslint/parser": "^8.15.0",
|
|
48
54
|
"@typescript-eslint/types": "^8.15.0",
|
|
49
55
|
"@typescript-eslint/utils": "^8.15.0",
|
|
50
56
|
"angular-eslint": "^19.0.0",
|
|
51
|
-
"eslint": "^8.57.0 || ^9.
|
|
57
|
+
"eslint": "^8.57.0 || ^9.22.0",
|
|
52
58
|
"eslint-import-resolver-node": "^0.3.4",
|
|
53
59
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
54
60
|
"eslint-plugin-import": "^2.31.0",
|
|
@@ -71,21 +77,20 @@
|
|
|
71
77
|
"@angular-devkit/schematics": "~19.2.0",
|
|
72
78
|
"@angular/compiler": "~19.2.0",
|
|
73
79
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
74
|
-
"@eslint/js": "~9.
|
|
75
|
-
"@nx/eslint-plugin": "~20.
|
|
76
|
-
"@o3r/build-helpers": "^12.3.0-
|
|
77
|
-
"@o3r/eslint-plugin": "^12.3.0-
|
|
78
|
-
"@o3r/
|
|
79
|
-
"@o3r/test-helpers": "^12.3.0-prerelease.9",
|
|
80
|
+
"@eslint/js": "~9.26.0",
|
|
81
|
+
"@nx/eslint-plugin": "~20.8.0",
|
|
82
|
+
"@o3r/build-helpers": "^12.3.0-rc.0",
|
|
83
|
+
"@o3r/eslint-plugin": "^12.3.0-rc.0",
|
|
84
|
+
"@o3r/test-helpers": "^12.3.0-rc.0",
|
|
80
85
|
"@schematics/angular": "~19.2.0",
|
|
81
86
|
"@stylistic/eslint-plugin": "~3.1.0",
|
|
82
87
|
"@types/eslint__js": "^8.42.3",
|
|
83
88
|
"@types/jest": "~29.5.2",
|
|
84
89
|
"@types/node": "^20.0.0",
|
|
85
|
-
"@typescript-eslint/parser": "~8.
|
|
86
|
-
"angular-eslint": "~19.
|
|
90
|
+
"@typescript-eslint/parser": "~8.32.0",
|
|
91
|
+
"angular-eslint": "~19.4.0",
|
|
87
92
|
"cpy-cli": "^5.0.0",
|
|
88
|
-
"eslint": "~9.
|
|
93
|
+
"eslint": "~9.26.0",
|
|
89
94
|
"eslint-import-resolver-node": "~0.3.9",
|
|
90
95
|
"eslint-import-resolver-typescript": "~3.10.0",
|
|
91
96
|
"eslint-plugin-import": "~2.31.0",
|
|
@@ -99,7 +104,7 @@
|
|
|
99
104
|
"jest": "~29.7.0",
|
|
100
105
|
"jest-junit": "~16.0.0",
|
|
101
106
|
"jsonc-eslint-parser": "~2.4.0",
|
|
102
|
-
"nx": "~20.
|
|
107
|
+
"nx": "~20.8.0",
|
|
103
108
|
"pid-from-port": "^1.1.3",
|
|
104
109
|
"rxjs": "^7.8.1",
|
|
105
110
|
"semver": "^7.5.2",
|
|
@@ -108,7 +113,7 @@
|
|
|
108
113
|
"tslib": "^2.6.2",
|
|
109
114
|
"type-fest": "^4.30.1",
|
|
110
115
|
"typescript": "~5.8.2",
|
|
111
|
-
"typescript-eslint": "~8.
|
|
116
|
+
"typescript-eslint": "~8.32.0"
|
|
112
117
|
},
|
|
113
118
|
"peerDependenciesMeta": {
|
|
114
119
|
"@angular-devkit/core": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/eslint/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAQL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/eslint/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAQL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAyCpC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,cAAc,MAAM,KAAG,IA2D3E,CAAC"}
|
|
@@ -4,12 +4,12 @@ exports.updateEslintConfig = void 0;
|
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
const core_1 = require("@angular-devkit/core");
|
|
6
6
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
7
|
+
const schematics_2 = require("@o3r/schematics");
|
|
7
8
|
const index_1 = require("../tsconfig/index");
|
|
8
|
-
const editAngularJson = (projectName, extension) =>
|
|
9
|
+
const editAngularJson = (projectName, extension) => (tree, context) => {
|
|
9
10
|
let workspace = null;
|
|
10
11
|
try {
|
|
11
|
-
|
|
12
|
-
workspace = getWorkspaceConfig(tree);
|
|
12
|
+
workspace = (0, schematics_2.getWorkspaceConfig)(tree);
|
|
13
13
|
}
|
|
14
14
|
catch {
|
|
15
15
|
context.logger.warn(`No @o3r/schematics installed, we could not detect the workspace. The linter task for ${projectName} can not be added.`);
|
|
@@ -37,13 +37,12 @@ const editAngularJson = (projectName, extension) => async (tree, context) => {
|
|
|
37
37
|
* @param rootPath
|
|
38
38
|
* @param projectName
|
|
39
39
|
*/
|
|
40
|
-
const updateEslintConfig = (rootPath, projectName) =>
|
|
41
|
-
const
|
|
42
|
-
const workspace = getWorkspaceConfig(tree);
|
|
40
|
+
const updateEslintConfig = (rootPath, projectName) => (tree, context) => {
|
|
41
|
+
const workspace = (0, schematics_2.getWorkspaceConfig)(tree);
|
|
43
42
|
const workspaceProject = workspace?.projects[projectName || ''];
|
|
44
43
|
const projectRootPath = workspaceProject?.root || '.';
|
|
45
44
|
const workingDir = tree.getDir(projectRootPath);
|
|
46
|
-
const eslintConfigFiles = findFilesInTree(workingDir, (file) => /eslint.config.[cm]?js/.test(file));
|
|
45
|
+
const eslintConfigFiles = (0, schematics_2.findFilesInTree)(workingDir, (file) => /eslint.config.[cm]?js/.test(file));
|
|
47
46
|
if (eslintConfigFiles.length > 1) {
|
|
48
47
|
context.logger.warn('Unable to add the "@o3r/eslint-config" recommendation because several ESLint config file detected.\n'
|
|
49
48
|
+ eslintConfigFiles.map((file) => `\t- ${file.path.toString()}`).join('\n'));
|
|
@@ -56,7 +55,7 @@ const updateEslintConfig = (rootPath, projectName) => async (tree, context) => {
|
|
|
56
55
|
oldConfig: '',
|
|
57
56
|
relativePathToRoot: path.posix.relative(projectRootPath, '.'),
|
|
58
57
|
packageName: tree.readJson(workingDir.file((0, core_1.fragment)('package.json'))?.path || 'package.json').name,
|
|
59
|
-
detectedTsConfigs: findFilesInTree(workingDir, (f) => /tsconfig\..*\.json/.test(f)).map((entry) => path.basename(entry.path)).concat('tsconfig.eslint.json'),
|
|
58
|
+
detectedTsConfigs: (0, schematics_2.findFilesInTree)(workingDir, (f) => /tsconfig\..*\.json/.test(f)).map((entry) => path.basename(entry.path)).concat('tsconfig.eslint.json'),
|
|
60
59
|
isApp: workspaceProject?.projectType === 'application'
|
|
61
60
|
};
|
|
62
61
|
if (eslintConfigFiles.length === 1) {
|
|
@@ -81,7 +80,7 @@ const updateEslintConfig = (rootPath, projectName) => async (tree, context) => {
|
|
|
81
80
|
projectName ? editAngularJson(projectName, templateOptions.extension) : (0, schematics_1.noop)(),
|
|
82
81
|
(0, schematics_1.applyToSubtree)(projectRootPath, [
|
|
83
82
|
(0, index_1.updateOrAddTsconfigEslint)(rootPath),
|
|
84
|
-
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(getTemplateFolder(rootPath, __dirname, `./templates/${projectRootPath === '.' ? 'workspace' : 'project'}`)), [
|
|
83
|
+
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)((0, schematics_2.getTemplateFolder)(rootPath, __dirname, `./templates/${projectRootPath === '.' ? 'workspace' : 'project'}`)), [
|
|
85
84
|
(0, schematics_1.template)(templateOptions),
|
|
86
85
|
(0, schematics_1.renameTemplateFiles)()
|
|
87
86
|
]), schematics_1.MergeStrategy.Overwrite)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/eslint/index.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,+CAG8B;AAC9B,2DAWoC;AACpC,gDAIyB;AAIzB,6CAE2B;AAE3B,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,SAAiB,EAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;IAC1F,IAAI,SAAS,GAA2B,IAAI,CAAC;IAC7C,IAAI,CAAC;QACH,SAAS,GAAG,IAAA,+BAAkB,EAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,wFAAwF,WAAW,oBAAoB,CAAC,CAAC;IAC/I,CAAC;IACD,MAAM,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AA,gCAAmB,GAAE;aACtB,CAAC,EAAE,0BAAa,CAAC,SAAS,CAAC;SAC7B,CACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA3DW,QAAA,kBAAkB,sBA2D7B"}
|
|
@@ -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,31 +1,35 @@
|
|
|
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
|
+
|
|
21
|
+
<%= extension === 'mjs' ? 'export default' : 'module.exports =' %> defineConfig([
|
|
12
22
|
{
|
|
13
23
|
name: '<%= packageName %>/projects',
|
|
14
24
|
languageOptions: {
|
|
15
25
|
sourceType: 'module',
|
|
16
26
|
parserOptions: {
|
|
17
27
|
tsconfigRootDir: __dirname,
|
|
18
|
-
|
|
19
|
-
<%= detectedTsConfigs.map((tsconfig) => ` '${tsconfig}'`).join(',\n') %>
|
|
20
|
-
]
|
|
28
|
+
projectService: true
|
|
21
29
|
}<% if (isApp) { %>,
|
|
22
30
|
globals: {
|
|
23
31
|
...globals.browser
|
|
24
32
|
}<% } %>
|
|
25
33
|
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: '<%= packageName %>/ignores',
|
|
29
|
-
ignores: []
|
|
30
34
|
}
|
|
31
|
-
];
|
|
35
|
+
]);
|
|
@@ -1,66 +1,20 @@
|
|
|
1
1
|
<% if (extension === 'mjs') { %>import {
|
|
2
|
+
mergeESLintFlatConfigs,
|
|
3
|
+
} from '@o3r/eslint-config/helpers';
|
|
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,22 +1,29 @@
|
|
|
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);
|
|
14
|
+
<% } else { %>const { defineConfig } = require('eslint/config');
|
|
15
|
+
<% } %>
|
|
7
16
|
|
|
8
|
-
|
|
17
|
+
<%= codeBeforeConfig %><%= extension === 'mjs' ? 'export default' : 'module.exports =' %> defineConfig([
|
|
9
18
|
{
|
|
10
19
|
name: '<%= packageName %>/projects',
|
|
11
20
|
languageOptions: {
|
|
12
21
|
sourceType: 'commonjs',
|
|
13
22
|
parserOptions: {
|
|
14
23
|
tsconfigRootDir: __dirname,
|
|
15
|
-
|
|
16
|
-
<%= detectedTsConfigs.map((tsconfig) => ` '${tsconfig}'`).join(',\n') %>
|
|
17
|
-
]
|
|
24
|
+
projectService: true
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
27
|
}
|
|
21
|
-
].concat(<%= oldConfig %>);
|
|
28
|
+
].concat(<%= oldConfig %>));
|
|
22
29
|
<%= 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,19 +30,19 @@ 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: {
|
|
29
42
|
'import/resolver': {
|
|
30
43
|
node: true,
|
|
31
44
|
typescript: {
|
|
32
|
-
|
|
33
|
-
<%= detectedTsConfigs.map((tsconfig) => ` join(__dirname, '${tsconfig}')`).join(',\n') %>
|
|
34
|
-
]
|
|
45
|
+
projectService: true
|
|
35
46
|
}
|
|
36
47
|
}
|
|
37
48
|
}
|
|
@@ -48,4 +59,4 @@ const o3rTemplate = require('@o3r/eslint-config/template');
|
|
|
48
59
|
]
|
|
49
60
|
}
|
|
50
61
|
}<% } %>
|
|
51
|
-
];
|
|
62
|
+
]);
|
|
@@ -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;
|
|
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;AAcpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAkHlB;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAI,SAAS,qBAAqB,SAA2C,CAAC"}
|
|
@@ -3,19 +3,14 @@ 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
|
-
const
|
|
9
|
-
logger.error(`[ERROR]: Adding @o3r/eslint-config has failed.
|
|
10
|
-
You need to install '@o3r/schematics' package to be able to use the eslint-config package. Please run 'ng add @o3r/schematics' .`);
|
|
11
|
-
throw reason;
|
|
12
|
-
};
|
|
13
|
-
const handleOtterEslintErrors = (projectName) => async (tree, context) => {
|
|
9
|
+
const handleOtterEslintErrors = (projectName) => (tree, context) => {
|
|
14
10
|
if (!projectName) {
|
|
15
11
|
return;
|
|
16
12
|
}
|
|
17
|
-
const
|
|
18
|
-
const workspace = getWorkspaceConfig(tree);
|
|
13
|
+
const workspace = (0, schematics_2.getWorkspaceConfig)(tree);
|
|
19
14
|
if (!workspace) {
|
|
20
15
|
return;
|
|
21
16
|
}
|
|
@@ -74,22 +69,21 @@ function ngAddFn(options) {
|
|
|
74
69
|
'yaml-eslint-parser',
|
|
75
70
|
...(options.projectName ? ['@angular-eslint/builder'] : [])
|
|
76
71
|
];
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const workspaceProject = options.projectName ? getWorkspaceConfig(tree)?.projects[options.projectName] : undefined;
|
|
72
|
+
const depsInfo = (0, schematics_2.getO3rPeerDeps)(path.resolve(__dirname, '..', '..', 'package.json'), true, /^@(?:o3r|ama-sdk)/);
|
|
73
|
+
const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
|
|
80
74
|
const { NodeDependencyType } = await Promise.resolve().then(() => require('@schematics/angular/utility/dependencies'));
|
|
81
75
|
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
|
|
82
76
|
const dependencies = depsInfo.o3rPeerDeps.reduce((acc, dep) => {
|
|
83
77
|
acc[dep] = {
|
|
84
78
|
inManifest: [{
|
|
85
79
|
range: `${options.exactO3rVersion ? '' : '~'}${depsInfo.packageVersion}`,
|
|
86
|
-
types: getProjectNewDependenciesTypes(workspaceProject)
|
|
80
|
+
types: (0, schematics_2.getProjectNewDependenciesTypes)(workspaceProject)
|
|
87
81
|
}],
|
|
88
82
|
ngAddOptions: { exactO3rVersion: options.exactO3rVersion }
|
|
89
83
|
};
|
|
90
84
|
return acc;
|
|
91
|
-
}, getPackageInstallConfig(packageJsonPath, tree, options.projectName, true, !!options.exactO3rVersion));
|
|
92
|
-
Object.entries(getExternalDependenciesVersionRange(devDependenciesToInstall, packageJsonPath, context.logger))
|
|
85
|
+
}, (0, schematics_2.getPackageInstallConfig)(packageJsonPath, tree, options.projectName, true, !!options.exactO3rVersion));
|
|
86
|
+
Object.entries((0, schematics_2.getExternalDependenciesVersionRange)(devDependenciesToInstall, packageJsonPath, context.logger))
|
|
93
87
|
.forEach(([dep, range]) => {
|
|
94
88
|
dependencies[dep] = {
|
|
95
89
|
inManifest: [{
|
|
@@ -99,7 +93,7 @@ function ngAddFn(options) {
|
|
|
99
93
|
};
|
|
100
94
|
});
|
|
101
95
|
return () => (0, schematics_1.chain)([
|
|
102
|
-
setupDependencies({
|
|
96
|
+
(0, schematics_2.setupDependencies)({
|
|
103
97
|
projectName: options.projectName,
|
|
104
98
|
dependencies,
|
|
105
99
|
ngAddToRun: depsInfo.o3rPeerDeps
|
|
@@ -111,7 +105,8 @@ function ngAddFn(options) {
|
|
|
111
105
|
(0, index_1.updateEslintConfig)(__dirname, options.projectName),
|
|
112
106
|
options.fix ? handleOtterEslintErrors(options.projectName) : (0, schematics_1.noop)()
|
|
113
107
|
])
|
|
114
|
-
: (0, schematics_1.noop)()
|
|
108
|
+
: (0, schematics_1.noop)(),
|
|
109
|
+
options.skipLinter ? (0, schematics_1.noop)() : (0, schematics_2.applyEditorConfig)()
|
|
115
110
|
])(tree, context);
|
|
116
111
|
};
|
|
117
112
|
}
|
|
@@ -119,9 +114,6 @@ function ngAddFn(options) {
|
|
|
119
114
|
* Add Otter eslint-config to an Angular Project
|
|
120
115
|
* @param options Options for the schematic
|
|
121
116
|
*/
|
|
122
|
-
const ngAdd = (options) =>
|
|
123
|
-
const { createOtterSchematic } = await Promise.resolve().then(() => require('@o3r/schematics')).catch(reportMissingSchematicsDep(logger));
|
|
124
|
-
return createOtterSchematic(ngAddFn)(options);
|
|
125
|
-
};
|
|
117
|
+
const ngAdd = (options) => (0, schematics_2.createOtterSchematic)(ngAddFn)(options);
|
|
126
118
|
exports.ngAdd = ngAdd;
|
|
127
119
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,2DAMoC;AACpC,gDASyB;AACzB,0CAEwB;AAIxB,0CAEwB;AAExB,MAAM,uBAAuB,GAAG,CAAC,WAAmB,EAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;IAC/E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;IACT,CAAC;IACD,MAAM,SAAS,GAAG,IAAA,+BAAkB,EAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,MAAM,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;QAC1E,OAAO;IACT,CAAC;IACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC;IAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IAC/D,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,mIAAmI,GAAG,aAAa,CAAC,CAAC;IAClL,CAAC;IACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,0BAA0B,CAAC,C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EAAE;YACxB,YAAY,CAAC,GAAG,CAAC,GAAG;gBAClB,UAAU,EAAE,CAAC;wBACX,KAAK;wBACL,KAAK,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC;qBAChC,CAAC;aACH,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE,CAAC,IAAA,kBAAK,EAAC;YACjB,IAAA,8BAAiB,EAAC;gBAChB,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,YAAY;gBACZ,UAAU,EAAE,QAAQ,CAAC,WAAW;aACjC,CAAC;YACF,oBAAY;YACZ,IAAA,0BAAkB,EAAC,SAAS,CAAC;YAC7B,OAAO,CAAC,WAAW,IAAI,gBAAgB,EAAE,IAAI;gBAC3C,CAAC,CAAC,IAAA,kBAAK,EAAC;oBACN,IAAA,0BAAkB,EAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC;oBAClD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,uBAAuB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE;iBACpE,CAAC;gBACF,CAAC,CAAC,IAAA,iBAAI,GAAE;YACV,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,IAAA,8BAAiB,GAAE;SAClD,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACI,MAAM,KAAK,GAAG,CAAC,OAA8B,EAAE,EAAE,CAAC,IAAA,iCAAoB,EAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AAAnF,QAAA,KAAK,SAA8E"}
|
|
@@ -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;
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":""}
|
|
@@ -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,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/tsconfig/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/tsconfig/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAIpC;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,MAAM,EAAE,wBAA4B,KAAG,IAa1F,CAAC"}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateOrAddTsconfigEslint = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const schematics_2 = require("@o3r/schematics");
|
|
5
6
|
/**
|
|
6
7
|
* Update or add tsconfig.eslint.json file
|
|
7
8
|
* @param rootPath
|
|
8
9
|
* @param projectTsConfig
|
|
9
10
|
*/
|
|
10
|
-
const updateOrAddTsconfigEslint = (rootPath, projectTsConfig = 'tsconfig') =>
|
|
11
|
+
const updateOrAddTsconfigEslint = (rootPath, projectTsConfig = 'tsconfig') => (tree) => {
|
|
11
12
|
const tsconfigPath = 'tsconfig.eslint.json';
|
|
12
13
|
if (tree.exists(tsconfigPath)) {
|
|
13
14
|
const tsconfig = tree.readJson(tsconfigPath);
|
|
@@ -15,8 +16,7 @@ const updateOrAddTsconfigEslint = (rootPath, projectTsConfig = 'tsconfig') => as
|
|
|
15
16
|
tree.overwrite(tsconfigPath, JSON.stringify(tsconfig, null, 2));
|
|
16
17
|
return () => tree;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
return () => (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(getTemplateFolder(rootPath, __dirname)), [
|
|
19
|
+
return () => (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)((0, schematics_2.getTemplateFolder)(rootPath, __dirname)), [
|
|
20
20
|
(0, schematics_1.template)({ projectTsConfig }),
|
|
21
21
|
(0, schematics_1.renameTemplateFiles)()
|
|
22
22
|
]), schematics_1.MergeStrategy.Overwrite);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/tsconfig/index.ts"],"names":[],"mappings":";;;AAIA,2DAQoC;AACpC,gDAEyB;AACzB;;;;GAIG;AACI,MAAM,yBAAyB,GAAG,CAAC,QAAgB,EAAE,eAAe,GAAG,UAAU,EAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;IAC1G,MAAM,YAAY,GAAG,sBAAsB,CAAC;IAC5C,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAe,CAAC;QAC3D,QAAQ,CAAC,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAoB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACtF,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChE,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,EAAE,CAAC,IAAA,sBAAS,EAAC,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,IAAA,8BAAiB,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE;QACxE,IAAA,qBAAQ,EAAC,EAAE,eAAe,EAAE,CAAC;QAC7B,IAAA,gCAAmB,GAAE;KACtB,CAAC,EAAE,0BAAa,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC,CAAC;AAbW,QAAA,yBAAyB,6BAapC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/vscode/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,IAAI,EACV,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/vscode/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,IAAI,EACV,MAAM,4BAA4B,CAAC;AAuCpC;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,IAuB1B,CAAC"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateVscode = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const schematics_2 = require("@o3r/schematics");
|
|
5
6
|
/**
|
|
6
7
|
* Update VSCode recommendations and settings
|
|
7
8
|
*/
|
|
8
|
-
const updateVscode =
|
|
9
|
-
const { addVsCodeRecommendations } = await Promise.resolve().then(() => require('@o3r/schematics'));
|
|
9
|
+
const updateVscode = () => {
|
|
10
10
|
return (0, schematics_1.chain)([
|
|
11
|
-
addVsCodeRecommendations(['dbaeumer.vscode-eslint']),
|
|
11
|
+
(0, schematics_2.addVsCodeRecommendations)(['dbaeumer.vscode-eslint']),
|
|
12
12
|
(tree) => {
|
|
13
13
|
const vscodeSettingsPath = '.vscode/settings.json';
|
|
14
14
|
const settings = (tree.exists(vscodeSettingsPath) ? (tree.readJson(vscodeSettingsPath) || {}) : {});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/vscode/index.ts"],"names":[],"mappings":";;;AAGA,2DAGoC;AACpC,gDAEyB;AAoCzB;;GAEG;AACI,MAAM,YAAY,GAAS,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C;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAvBW,QAAA,YAAY,gBAuBvB"}
|
|
@@ -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
|
+
};
|