@o3r/eslint-config 12.3.0-prerelease.6 → 12.3.0-prerelease.60
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 +20 -15
- 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/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/schema.d.ts +2 -0
- package/schematics/ng-add/schema.d.ts.map +1 -1
- 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/vscode/index.d.ts.map +1 -1
- package/schematics/ng-add/vscode/index.js +3 -3
- 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.60",
|
|
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-prerelease.60"
|
|
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-prerelease.
|
|
44
|
-
"@o3r/schematics": "^12.3.0-prerelease.
|
|
48
|
+
"@eslint/js": "^8.57.0 || ^9.22.0",
|
|
49
|
+
"@o3r/eslint-plugin": "^12.3.0-prerelease.60",
|
|
50
|
+
"@o3r/schematics": "^12.3.0-prerelease.60",
|
|
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-prerelease.
|
|
77
|
-
"@o3r/eslint-plugin": "^12.3.0-prerelease.
|
|
78
|
-
"@o3r/
|
|
79
|
-
"@o3r/test-helpers": "^12.3.0-prerelease.6",
|
|
80
|
+
"@eslint/js": "~9.25.0",
|
|
81
|
+
"@nx/eslint-plugin": "~20.8.0",
|
|
82
|
+
"@o3r/build-helpers": "^12.3.0-prerelease.60",
|
|
83
|
+
"@o3r/eslint-plugin": "^12.3.0-prerelease.60",
|
|
84
|
+
"@o3r/test-helpers": "^12.3.0-prerelease.60",
|
|
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.
|
|
90
|
+
"@typescript-eslint/parser": "~8.31.0",
|
|
86
91
|
"angular-eslint": "~19.3.0",
|
|
87
92
|
"cpy-cli": "^5.0.0",
|
|
88
|
-
"eslint": "~9.
|
|
93
|
+
"eslint": "~9.25.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.31.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)
|
|
@@ -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
|
|
@@ -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"}
|
|
@@ -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);
|
|
@@ -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,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
|
+
};
|