@angular-eslint/builder 17.5.3-alpha.1 → 17.5.3
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/README.md +0 -6
- package/dist/lint.impl.d.ts +2 -1
- package/dist/lint.impl.d.ts.map +1 -1
- package/dist/lint.impl.js +9 -8
- package/dist/utils/eslint-utils.d.ts.map +1 -1
- package/dist/utils/eslint-utils.js +2 -12
- package/package.json +2 -6
package/README.md
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
1
|
# @angular-eslint/builder
|
|
2
|
-
|
|
3
|
-
Please see https://github.com/angular-eslint/angular-eslint for full usage instructions and guidance.
|
|
4
|
-
|
|
5
|
-
The `@angular-eslint/builder` package is a custom Angular CLI builder that allows you to run ESLint on your Angular CLI projects.
|
|
6
|
-
|
|
7
|
-
It wraps the ESLint programmatic node API (https://eslint.org/docs/latest/integrate/nodejs-api) to provide a seamless experience via `ng lint` that is closely equivalent to using the `eslint` CLI directly.
|
package/dist/lint.impl.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Schema } from './schema';
|
|
2
|
+
declare const _default: import("@angular-devkit/architect/src/internal").Builder<Schema & import("@angular-devkit/core").JsonObject>;
|
|
2
3
|
export default _default;
|
|
3
4
|
//# sourceMappingURL=lint.impl.d.ts.map
|
package/dist/lint.impl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.impl.d.ts","sourceRoot":"","sources":["../src/lint.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lint.impl.d.ts","sourceRoot":"","sources":["../src/lint.impl.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;;AAGvC,wBA+LE"}
|
package/dist/lint.impl.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const architect_1 = require("@angular-devkit/architect");
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const eslint_utils_1 = require("./utils/eslint-utils");
|
|
7
|
-
exports.default = (0,
|
|
8
|
-
const systemRoot = context.
|
|
7
|
+
exports.default = (0, architect_1.createBuilder)(async (options, context) => {
|
|
8
|
+
const systemRoot = context.workspaceRoot;
|
|
9
9
|
// eslint resolves files relative to the current working directory.
|
|
10
10
|
// We want these paths to always be resolved relative to the workspace
|
|
11
11
|
// root to be able to run the lint executor from any subfolder.
|
|
12
12
|
process.chdir(systemRoot);
|
|
13
|
-
const projectName = context.
|
|
13
|
+
const projectName = context.target?.project ?? '<???>';
|
|
14
14
|
const printInfo = options.format && !options.silent;
|
|
15
15
|
if (printInfo) {
|
|
16
16
|
console.info(`\nLinting ${JSON.stringify(projectName)}...`);
|
|
@@ -30,7 +30,7 @@ exports.default = (0, devkit_1.convertNxExecutor)(async (options, context) => {
|
|
|
30
30
|
* we only want to support it if the user has explicitly opted into it by converting
|
|
31
31
|
* their root ESLint config to use eslint.config.js
|
|
32
32
|
*/
|
|
33
|
-
const useFlatConfig = (0, fs_1.existsSync)((0,
|
|
33
|
+
const useFlatConfig = (0, fs_1.existsSync)((0, path_1.join)(systemRoot, 'eslint.config.js'));
|
|
34
34
|
const { eslint, ESLint } = await (0, eslint_utils_1.resolveAndInstantiateESLint)(eslintConfigPath, options, useFlatConfig);
|
|
35
35
|
const version = ESLint?.version?.split('.');
|
|
36
36
|
if (!version ||
|
|
@@ -47,8 +47,9 @@ exports.default = (0, devkit_1.convertNxExecutor)(async (options, context) => {
|
|
|
47
47
|
if (err instanceof Error &&
|
|
48
48
|
err.message.includes('You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser')) {
|
|
49
49
|
let eslintConfigPathForError = `for ${projectName}`;
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
const projectMetadata = await context.getProjectMetadata(projectName);
|
|
51
|
+
if (projectMetadata?.root) {
|
|
52
|
+
const { root } = projectMetadata;
|
|
52
53
|
eslintConfigPathForError = `\`${root}/.eslintrc.json\``;
|
|
53
54
|
}
|
|
54
55
|
console.error(`
|
|
@@ -111,7 +112,7 @@ For full guidance on how to resolve this issue, please see https://github.com/an
|
|
|
111
112
|
*/
|
|
112
113
|
const formattedResults = await formatter.format(finalLintResults);
|
|
113
114
|
if (options.outputFile) {
|
|
114
|
-
const pathToOutputFile = (0, path_1.join)(
|
|
115
|
+
const pathToOutputFile = (0, path_1.join)(systemRoot, options.outputFile);
|
|
115
116
|
(0, fs_1.mkdirSync)((0, path_1.dirname)(pathToOutputFile), { recursive: true });
|
|
116
117
|
(0, fs_1.writeFileSync)(pathToOutputFile, formattedResults);
|
|
117
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint-utils.d.ts","sourceRoot":"","sources":["../../src/utils/eslint-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"eslint-utils.d.ts","sourceRoot":"","sources":["../../src/utils/eslint-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAiBxC,wBAAsB,2BAA2B,CAC/C,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,OAAO,EAAE,MAAM,EACf,aAAa,UAAQ;;;GAoEtB"}
|
|
@@ -3,14 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveAndInstantiateESLint = void 0;
|
|
4
4
|
async function resolveESLintClass(useFlatConfig = false) {
|
|
5
5
|
try {
|
|
6
|
-
// In eslint 8.57.0 (the final v8 version), a dedicated API was added for resolving the correct ESLint class.
|
|
7
|
-
const eslint = await import('eslint');
|
|
8
|
-
if (typeof eslint.loadESLint === 'function') {
|
|
9
|
-
return await eslint.loadESLint({ useFlatConfig });
|
|
10
|
-
}
|
|
11
|
-
// If that API is not available (an older version of v8), we need to use the old way of resolving the ESLint class.
|
|
12
6
|
if (!useFlatConfig) {
|
|
13
|
-
return eslint.ESLint;
|
|
7
|
+
return (await import('eslint')).ESLint;
|
|
14
8
|
}
|
|
15
9
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
10
|
const { FlatESLint } = require('eslint/use-at-your-own-risk');
|
|
@@ -44,6 +38,7 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
|
44
38
|
* not be any html files in the project, so keeping it true would break linting every time
|
|
45
39
|
*/
|
|
46
40
|
errorOnUnmatchedPattern: false,
|
|
41
|
+
reportUnusedDisableDirectives: options.reportUnusedDisableDirectives || undefined,
|
|
47
42
|
};
|
|
48
43
|
if (useFlatConfig) {
|
|
49
44
|
if (typeof options.useEslintrc !== 'undefined') {
|
|
@@ -55,9 +50,6 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
|
55
50
|
if (options.ignorePath !== undefined) {
|
|
56
51
|
throw new Error('For Flat Config, ESLint removed `ignorePath` and so it is not supported as an option. See https://eslint.org/docs/latest/use/configure/configuration-files-new');
|
|
57
52
|
}
|
|
58
|
-
if (options.reportUnusedDisableDirectives) {
|
|
59
|
-
throw new Error('For Flat Config, ESLint removed `reportedUnusedDisableDirectives` and so it is not supported as an option. See https://eslint.org/docs/latest/use/configure/configuration-files-new');
|
|
60
|
-
}
|
|
61
53
|
}
|
|
62
54
|
else {
|
|
63
55
|
eslintOptions.rulePaths = options.rulesdir || [];
|
|
@@ -69,8 +61,6 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
|
69
61
|
* merge the provided config with others it finds automatically.
|
|
70
62
|
*/
|
|
71
63
|
eslintOptions.useEslintrc = !options.noEslintrc;
|
|
72
|
-
eslintOptions.reportUnusedDisableDirectives =
|
|
73
|
-
options.reportUnusedDisableDirectives || undefined;
|
|
74
64
|
}
|
|
75
65
|
const eslint = new ESLint(eslintOptions);
|
|
76
66
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/builder",
|
|
3
|
-
"version": "17.5.3
|
|
3
|
+
"version": "17.5.3",
|
|
4
4
|
"description": "Angular CLI builder for ESLint",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,13 +18,9 @@
|
|
|
18
18
|
"LICENSE",
|
|
19
19
|
"builders.json"
|
|
20
20
|
],
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@nx/devkit": "^19.0.6",
|
|
23
|
-
"nx": "^19.0.6"
|
|
24
|
-
},
|
|
25
21
|
"builders": "./builders.json",
|
|
26
22
|
"peerDependencies": {
|
|
27
|
-
"eslint": "^
|
|
23
|
+
"eslint": "^7.20.0 || ^8.0.0",
|
|
28
24
|
"typescript": "*"
|
|
29
25
|
},
|
|
30
26
|
"gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
|