@nx/eslint 0.0.0-pr-22179-271588f
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/LICENSE +22 -0
- package/README.md +66 -0
- package/executors.json +10 -0
- package/generators.json +28 -0
- package/index.d.ts +4 -0
- package/index.js +14 -0
- package/migrations.json +138 -0
- package/package.json +52 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +5 -0
- package/src/executors/lint/hasher.d.ts +9 -0
- package/src/executors/lint/hasher.js +43 -0
- package/src/executors/lint/lint.impl.d.ts +5 -0
- package/src/executors/lint/lint.impl.js +174 -0
- package/src/executors/lint/schema.d.ts +40 -0
- package/src/executors/lint/schema.json +148 -0
- package/src/executors/lint/utility/eslint-utils.d.ts +6 -0
- package/src/executors/lint/utility/eslint-utils.js +75 -0
- package/src/generators/convert-to-flat-config/converters/json-converter.d.ts +11 -0
- package/src/generators/convert-to-flat-config/converters/json-converter.js +175 -0
- package/src/generators/convert-to-flat-config/generator.d.ts +4 -0
- package/src/generators/convert-to-flat-config/generator.js +139 -0
- package/src/generators/convert-to-flat-config/schema.d.ts +3 -0
- package/src/generators/convert-to-flat-config/schema.json +17 -0
- package/src/generators/init/global-eslint-config.d.ts +29 -0
- package/src/generators/init/global-eslint-config.js +102 -0
- package/src/generators/init/init-migration.d.ts +3 -0
- package/src/generators/init/init-migration.js +137 -0
- package/src/generators/init/init.d.ts +9 -0
- package/src/generators/init/init.js +93 -0
- package/src/generators/init/schema.json +28 -0
- package/src/generators/lint-project/lint-project.d.ts +22 -0
- package/src/generators/lint-project/lint-project.js +227 -0
- package/src/generators/lint-project/setup-root-eslint.d.ts +7 -0
- package/src/generators/lint-project/setup-root-eslint.js +33 -0
- package/src/generators/utils/eslint-file.d.ts +16 -0
- package/src/generators/utils/eslint-file.js +287 -0
- package/src/generators/utils/eslint-targets.d.ts +2 -0
- package/src/generators/utils/eslint-targets.js +18 -0
- package/src/generators/utils/flat-config/ast-utils.d.ts +60 -0
- package/src/generators/utils/flat-config/ast-utils.js +573 -0
- package/src/generators/utils/flat-config/path-utils.d.ts +3 -0
- package/src/generators/utils/flat-config/path-utils.js +28 -0
- package/src/generators/utils/linter.d.ts +4 -0
- package/src/generators/utils/linter.js +8 -0
- package/src/generators/utils/plugin.d.ts +2 -0
- package/src/generators/utils/plugin.js +11 -0
- package/src/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +11 -0
- package/src/generators/workspace-rule/files/__name__.ts__tmpl__ +37 -0
- package/src/generators/workspace-rule/schema.json +26 -0
- package/src/generators/workspace-rule/workspace-rule.d.ts +6 -0
- package/src/generators/workspace-rule/workspace-rule.js +78 -0
- package/src/generators/workspace-rules-project/files/index.ts__tmpl__ +27 -0
- package/src/generators/workspace-rules-project/files/tsconfig.json__tmpl__ +14 -0
- package/src/generators/workspace-rules-project/files/tsconfig.lint.json__tmpl__ +9 -0
- package/src/generators/workspace-rules-project/schema.json +23 -0
- package/src/generators/workspace-rules-project/workspace-rules-project.d.ts +8 -0
- package/src/generators/workspace-rules-project/workspace-rules-project.js +82 -0
- package/src/migrations/update-15-0-0/add-eslint-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-eslint-inputs.js +27 -0
- package/src/migrations/update-15-7-1/add-eslint-ignore.d.ts +2 -0
- package/src/migrations/update-15-7-1/add-eslint-ignore.js +36 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.d.ts +2 -0
- package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.js +44 -0
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.d.ts +2 -0
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.js +47 -0
- package/src/migrations/update-17-1-0/update-typescript-eslint.d.ts +2 -0
- package/src/migrations/update-17-1-0/update-typescript-eslint.js +74 -0
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.d.ts +2 -0
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.js +46 -0
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.js +107 -0
- package/src/plugins/plugin.d.ts +5 -0
- package/src/plugins/plugin.js +92 -0
- package/src/utils/config-file.d.ts +5 -0
- package/src/utils/config-file.js +35 -0
- package/src/utils/flat-config.d.ts +2 -0
- package/src/utils/flat-config.js +7 -0
- package/src/utils/rules-requiring-type-checking.d.ts +3 -0
- package/src/utils/rules-requiring-type-checking.js +84 -0
- package/src/utils/versions.d.ts +5 -0
- package/src/utils/versions.js +8 -0
- package/src/utils/workspace-lint-rules.d.ts +1 -0
- package/src/utils/workspace-lint-rules.js +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-2023 Narwhal Technologies Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<p style="text-align: center;">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
+
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<div style="text-align: center;">
|
|
9
|
+
|
|
10
|
+
[](https://circleci.com/gh/nrwl/nx)
|
|
11
|
+
[]()
|
|
12
|
+
[](https://www.npmjs.com/@nx/workspace)
|
|
13
|
+
[]()
|
|
14
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
15
|
+
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
16
|
+
[](https://go.nx.dev/community)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<hr>
|
|
22
|
+
|
|
23
|
+
# Nx: Smart Monorepos · Fast CI
|
|
24
|
+
|
|
25
|
+
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
26
|
+
|
|
27
|
+
## Getting Started
|
|
28
|
+
|
|
29
|
+
### Creating an Nx Workspace
|
|
30
|
+
|
|
31
|
+
**Using `npx`**
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx create-nx-workspace
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Using `npm init`**
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm init nx-workspace
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Using `yarn create`**
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn create nx-workspace
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Adding Nx to an Existing Repository
|
|
50
|
+
|
|
51
|
+
Run:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx nx@latest init
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Documentation & Resources
|
|
58
|
+
|
|
59
|
+
- [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
|
|
60
|
+
- [Intro to Nx](https://nx.dev/getting-started/intro)
|
|
61
|
+
- [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
|
|
62
|
+
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
63
|
+
|
|
64
|
+
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
65
|
+
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
66
|
+
|
package/executors.json
ADDED
package/generators.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nx/eslint",
|
|
3
|
+
"version": "0.1",
|
|
4
|
+
"generators": {
|
|
5
|
+
"init": {
|
|
6
|
+
"factory": "./src/generators/init/init#initEsLint",
|
|
7
|
+
"schema": "./src/generators/init/schema.json",
|
|
8
|
+
"description": "Set up the ESLint plugin.",
|
|
9
|
+
"hidden": true
|
|
10
|
+
},
|
|
11
|
+
"workspace-rules-project": {
|
|
12
|
+
"factory": "./src/generators/workspace-rules-project/workspace-rules-project#lintWorkspaceRulesProjectGenerator",
|
|
13
|
+
"schema": "./src/generators/workspace-rules-project/schema.json",
|
|
14
|
+
"description": "Create the Workspace Lint Rules Project.",
|
|
15
|
+
"hidden": true
|
|
16
|
+
},
|
|
17
|
+
"workspace-rule": {
|
|
18
|
+
"factory": "./src/generators/workspace-rule/workspace-rule#lintWorkspaceRuleGenerator",
|
|
19
|
+
"schema": "./src/generators/workspace-rule/schema.json",
|
|
20
|
+
"description": "Create a new Workspace ESLint rule."
|
|
21
|
+
},
|
|
22
|
+
"convert-to-flat-config": {
|
|
23
|
+
"factory": "./src/generators/convert-to-flat-config/generator",
|
|
24
|
+
"schema": "./src/generators/convert-to-flat-config/schema.json",
|
|
25
|
+
"description": "Convert an Nx workspace's ESLint configs to use Flat Config."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { lintProjectGenerator } from './src/generators/lint-project/lint-project';
|
|
2
|
+
export { lintInitGenerator } from './src/generators/init/init';
|
|
3
|
+
export { Linter } from './src/generators/utils/linter';
|
|
4
|
+
export { hasRulesRequiringTypeChecking } from './src/utils/rules-requiring-type-checking';
|
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasRulesRequiringTypeChecking = exports.Linter = exports.lintInitGenerator = exports.lintProjectGenerator = void 0;
|
|
4
|
+
var lint_project_1 = require("./src/generators/lint-project/lint-project");
|
|
5
|
+
Object.defineProperty(exports, "lintProjectGenerator", { enumerable: true, get: function () { return lint_project_1.lintProjectGenerator; } });
|
|
6
|
+
var init_1 = require("./src/generators/init/init");
|
|
7
|
+
Object.defineProperty(exports, "lintInitGenerator", { enumerable: true, get: function () { return init_1.lintInitGenerator; } });
|
|
8
|
+
var linter_1 = require("./src/generators/utils/linter");
|
|
9
|
+
Object.defineProperty(exports, "Linter", { enumerable: true, get: function () { return linter_1.Linter; } });
|
|
10
|
+
// @nx/angular needs it for the Angular CLI workspace migration to Nx to
|
|
11
|
+
// infer whether a config is using type aware rules and set the
|
|
12
|
+
// `hasTypeAwareRules` option of the `@nx/eslint:lint` executor.
|
|
13
|
+
var rules_requiring_type_checking_1 = require("./src/utils/rules-requiring-type-checking");
|
|
14
|
+
Object.defineProperty(exports, "hasRulesRequiringTypeChecking", { enumerable: true, get: function () { return rules_requiring_type_checking_1.hasRulesRequiringTypeChecking; } });
|
package/migrations.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"add-eslint-inputs": {
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"version": "15.0.0-beta.0",
|
|
6
|
+
"description": "Stop hashing eslint config files for build targets and dependent tasks",
|
|
7
|
+
"factory": "./src/migrations/update-15-0-0/add-eslint-inputs"
|
|
8
|
+
},
|
|
9
|
+
"add-eslint-ignore": {
|
|
10
|
+
"cli": "nx",
|
|
11
|
+
"version": "15.7.1-beta.0",
|
|
12
|
+
"description": "Add node_modules to root eslint ignore",
|
|
13
|
+
"factory": "./src/migrations/update-15-7-1/add-eslint-ignore"
|
|
14
|
+
},
|
|
15
|
+
"update-16-0-0-add-nx-packages": {
|
|
16
|
+
"cli": "nx",
|
|
17
|
+
"version": "16.0.0-beta.1",
|
|
18
|
+
"description": "Replace @nrwl/linter with @nx/linter",
|
|
19
|
+
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
20
|
+
},
|
|
21
|
+
"update-16-8-0-add-ignored-files": {
|
|
22
|
+
"version": "16.8.0",
|
|
23
|
+
"description": "update-16-8-0-add-ignored-files",
|
|
24
|
+
"implementation": "./src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files"
|
|
25
|
+
},
|
|
26
|
+
"update-17-0-0-rename-to-eslint": {
|
|
27
|
+
"version": "17.0.0-beta.7",
|
|
28
|
+
"description": "update-17-0-0-rename-to-eslint",
|
|
29
|
+
"implementation": "./src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint"
|
|
30
|
+
},
|
|
31
|
+
"update-typescript-eslint": {
|
|
32
|
+
"version": "17.1.0-beta.1",
|
|
33
|
+
"description": "Updates for @typescript-utils/utils v6.9.1+",
|
|
34
|
+
"implementation": "./src/migrations/update-17-1-0/update-typescript-eslint"
|
|
35
|
+
},
|
|
36
|
+
"simplify-eslint-patterns": {
|
|
37
|
+
"version": "17.2.0-beta.0",
|
|
38
|
+
"description": "Simplify eslintFilePatterns",
|
|
39
|
+
"implementation": "./src/migrations/update-17-2-0/simplify-eslint-patterns"
|
|
40
|
+
},
|
|
41
|
+
"move-options-to-target-defaults": {
|
|
42
|
+
"version": "17.2.9",
|
|
43
|
+
"description": "Move executor options to target defaults",
|
|
44
|
+
"implementation": "./src/migrations/update-17-2-9/move-options-to-target-defaults"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"packageJsonUpdates": {
|
|
48
|
+
"16.0.0": {
|
|
49
|
+
"version": "16.0.0-beta.0",
|
|
50
|
+
"packages": {
|
|
51
|
+
"@typescript-eslint/parser": {
|
|
52
|
+
"version": "^5.58.0"
|
|
53
|
+
},
|
|
54
|
+
"@typescript-eslint/eslint-plugin": {
|
|
55
|
+
"version": "^5.58.0"
|
|
56
|
+
},
|
|
57
|
+
"@typescript-eslint/utils": {
|
|
58
|
+
"version": "^5.58.0"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"16.5.0": {
|
|
63
|
+
"version": "16.5.0-beta.2",
|
|
64
|
+
"packages": {
|
|
65
|
+
"@typescript-eslint/parser": {
|
|
66
|
+
"version": "^5.60.1"
|
|
67
|
+
},
|
|
68
|
+
"@typescript-eslint/eslint-plugin": {
|
|
69
|
+
"version": "^5.60.1"
|
|
70
|
+
},
|
|
71
|
+
"@typescript-eslint/utils": {
|
|
72
|
+
"version": "^5.60.1"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"16.7.0": {
|
|
77
|
+
"version": "16.7.0-beta.2",
|
|
78
|
+
"packages": {
|
|
79
|
+
"eslint": {
|
|
80
|
+
"version": "~8.46.0"
|
|
81
|
+
},
|
|
82
|
+
"@typescript-eslint/parser": {
|
|
83
|
+
"version": "^5.60.1"
|
|
84
|
+
},
|
|
85
|
+
"@typescript-eslint/eslint-plugin": {
|
|
86
|
+
"version": "^5.60.1"
|
|
87
|
+
},
|
|
88
|
+
"@typescript-eslint/utils": {
|
|
89
|
+
"version": "^5.60.1"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"17.0.0": {
|
|
94
|
+
"version": "17.0.0-rc.2",
|
|
95
|
+
"packages": {
|
|
96
|
+
"eslint-config-prettier": {
|
|
97
|
+
"version": "^9.0.0"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"17.1.0": {
|
|
102
|
+
"version": "17.1.0-beta.1",
|
|
103
|
+
"packages": {
|
|
104
|
+
"@typescript-eslint/parser": {
|
|
105
|
+
"version": "^6.9.1"
|
|
106
|
+
},
|
|
107
|
+
"@typescript-eslint/eslint-plugin": {
|
|
108
|
+
"version": "^6.9.1"
|
|
109
|
+
},
|
|
110
|
+
"@typescript-eslint/utils": {
|
|
111
|
+
"version": "^6.9.1"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"17.2.0": {
|
|
116
|
+
"version": "17.2.0-beta.2",
|
|
117
|
+
"packages": {
|
|
118
|
+
"eslint": {
|
|
119
|
+
"version": "~8.48.0"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"17.3.0": {
|
|
124
|
+
"version": "17.3.0-beta.0",
|
|
125
|
+
"packages": {
|
|
126
|
+
"@typescript-eslint/parser": {
|
|
127
|
+
"version": "^6.13.2"
|
|
128
|
+
},
|
|
129
|
+
"@typescript-eslint/eslint-plugin": {
|
|
130
|
+
"version": "^6.13.2"
|
|
131
|
+
},
|
|
132
|
+
"@typescript-eslint/utils": {
|
|
133
|
+
"version": "^6.13.2"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx/eslint",
|
|
3
|
+
"version": "0.0.0-pr-22179-271588f",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "The ESLint plugin for Nx contains executors, generators and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/nrwl/nx.git",
|
|
9
|
+
"directory": "packages/eslint"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"Monorepo",
|
|
13
|
+
"Web",
|
|
14
|
+
"Lint",
|
|
15
|
+
"ESLint",
|
|
16
|
+
"CLI"
|
|
17
|
+
],
|
|
18
|
+
"main": "./index.js",
|
|
19
|
+
"typings": "./index.d.ts",
|
|
20
|
+
"author": "Victor Savkin",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/nrwl/nx/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://nx.dev",
|
|
26
|
+
"ng-update": {
|
|
27
|
+
"requirements": {},
|
|
28
|
+
"migrations": "./migrations.json"
|
|
29
|
+
},
|
|
30
|
+
"generators": "./generators.json",
|
|
31
|
+
"executors": "./executors.json",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"js-yaml": "4.1.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@nx/devkit": "0.0.0-pr-22179-271588f",
|
|
37
|
+
"@nx/js": "0.0.0-pr-22179-271588f",
|
|
38
|
+
"eslint": "^8.0.0",
|
|
39
|
+
"tslib": "^2.3.0",
|
|
40
|
+
"typescript": "~5.3.2",
|
|
41
|
+
"@nx/linter": "0.0.0-pr-22179-271588f"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"js-yaml": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"type": "commonjs"
|
|
52
|
+
}
|
package/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createNodes, EslintPluginOptions } from './src/plugins/plugin';
|
package/plugin.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodes = void 0;
|
|
4
|
+
var plugin_1 = require("./src/plugins/plugin");
|
|
5
|
+
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Hash, ProjectGraph, ProjectsConfigurations, Task, TaskGraph, TaskHasher } from '@nx/devkit';
|
|
3
|
+
export default function run(task: Task, context: {
|
|
4
|
+
hasher: TaskHasher;
|
|
5
|
+
projectGraph: ProjectGraph;
|
|
6
|
+
taskGraph: TaskGraph;
|
|
7
|
+
projectsConfigurations: ProjectsConfigurations;
|
|
8
|
+
env: NodeJS.ProcessEnv;
|
|
9
|
+
}): Promise<Hash>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
async function run(task, context) {
|
|
5
|
+
const res = await context.hasher.hashTask(task, context.taskGraph, context.env);
|
|
6
|
+
if (task.overrides['hasTypeAwareRules'] === true) {
|
|
7
|
+
return res;
|
|
8
|
+
}
|
|
9
|
+
const deps = allDeps(task.id, context.taskGraph, context.projectGraph);
|
|
10
|
+
const tags = (0, devkit_1.hashArray)(deps.map((d) => (context.projectsConfigurations.projects[d].tags || []).join('|')));
|
|
11
|
+
const command = res.details['command'];
|
|
12
|
+
let selfSource = '';
|
|
13
|
+
for (let n of Object.keys(res.details)) {
|
|
14
|
+
if (n.startsWith(`${task.target.project}:`)) {
|
|
15
|
+
selfSource = res.details.nodes[n];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const nodes = {};
|
|
19
|
+
const hashes = [];
|
|
20
|
+
for (const d of Object.keys(res.details.nodes).sort()) {
|
|
21
|
+
if (d.indexOf('$fileset') === -1) {
|
|
22
|
+
nodes[d] = res.details.nodes[d];
|
|
23
|
+
hashes.push(res.details.nodes[d]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
value: (0, devkit_1.hashArray)([command, selfSource, ...hashes, tags]),
|
|
28
|
+
details: {
|
|
29
|
+
command,
|
|
30
|
+
nodes: { [task.target.project]: selfSource, tags, ...nodes },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.default = run;
|
|
35
|
+
function allDeps(taskId, taskGraph, projectGraph) {
|
|
36
|
+
if (!taskGraph.tasks) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
const project = taskGraph.tasks[taskId].target.project;
|
|
40
|
+
return projectGraph.dependencies[project]
|
|
41
|
+
.filter((d) => !!projectGraph.nodes[d.target])
|
|
42
|
+
.map((d) => d.target);
|
|
43
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const eslint_utils_1 = require("./utility/eslint-utils");
|
|
7
|
+
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
8
|
+
async function run(options, context) {
|
|
9
|
+
// this is only used for the hasher
|
|
10
|
+
delete options.hasTypeAwareRules;
|
|
11
|
+
const systemRoot = context.root;
|
|
12
|
+
// eslint resolves files relative to the current working directory.
|
|
13
|
+
// We want these paths to always be resolved relative to the workspace
|
|
14
|
+
// root to be able to run the lint executor from any subfolder.
|
|
15
|
+
process.chdir(systemRoot);
|
|
16
|
+
const projectName = context.projectName || '<???>';
|
|
17
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
18
|
+
const printInfo = options.format && !options.silent;
|
|
19
|
+
if (printInfo) {
|
|
20
|
+
console.info(`\nLinting ${JSON.stringify(projectName)}...`);
|
|
21
|
+
}
|
|
22
|
+
options.cacheLocation = options.cacheLocation
|
|
23
|
+
? (0, devkit_1.joinPathFragments)(options.cacheLocation, projectName)
|
|
24
|
+
: undefined;
|
|
25
|
+
const { printConfig, errorOnUnmatchedPattern, ...normalizedOptions } = options;
|
|
26
|
+
/**
|
|
27
|
+
* Until ESLint v9 is released and the new so called flat config is the default
|
|
28
|
+
* we only want to support it if the user has explicitly opted into it by converting
|
|
29
|
+
* their root ESLint config to use eslint.config.js
|
|
30
|
+
*/
|
|
31
|
+
const hasFlatConfig = (0, fs_1.existsSync)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'eslint.config.js'));
|
|
32
|
+
// while standard eslint uses by default closest config to the file, if otherwise not specified,
|
|
33
|
+
// the flat config would always use the root config, so we need to explicitly set it to the local one
|
|
34
|
+
if (hasFlatConfig && !normalizedOptions.eslintConfig) {
|
|
35
|
+
const eslintConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, 'eslint.config.js');
|
|
36
|
+
if ((0, fs_1.existsSync)(eslintConfigPath)) {
|
|
37
|
+
normalizedOptions.eslintConfig = eslintConfigPath;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* We want users to have the option of not specifying the config path, and let
|
|
42
|
+
* eslint automatically resolve the `.eslintrc.json` files in each folder.
|
|
43
|
+
*/
|
|
44
|
+
let eslintConfigPath = normalizedOptions.eslintConfig
|
|
45
|
+
? (0, path_1.resolve)(systemRoot, normalizedOptions.eslintConfig)
|
|
46
|
+
: undefined;
|
|
47
|
+
const { eslint, ESLint } = await (0, eslint_utils_1.resolveAndInstantiateESLint)(eslintConfigPath, normalizedOptions, hasFlatConfig);
|
|
48
|
+
const version = ESLint.version?.split('.');
|
|
49
|
+
if (!version ||
|
|
50
|
+
version.length < 2 ||
|
|
51
|
+
Number(version[0]) < 7 ||
|
|
52
|
+
(Number(version[0]) === 7 && Number(version[1]) < 6)) {
|
|
53
|
+
throw new Error('ESLint must be version 7.6 or higher.');
|
|
54
|
+
}
|
|
55
|
+
if (printConfig) {
|
|
56
|
+
try {
|
|
57
|
+
const fileConfig = await eslint.calculateConfigForFile(printConfig);
|
|
58
|
+
console.log(JSON.stringify(fileConfig, null, ' '));
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
console.error(err);
|
|
65
|
+
return {
|
|
66
|
+
success: false,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
let lintResults = [];
|
|
71
|
+
const normalizedLintFilePatterns = normalizedOptions.lintFilePatterns.map((pattern) => {
|
|
72
|
+
return (0, utils_1.interpolate)(pattern, {
|
|
73
|
+
workspaceRoot: '',
|
|
74
|
+
projectRoot,
|
|
75
|
+
projectName: context.projectName,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
lintResults = await eslint.lintFiles(normalizedLintFilePatterns);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (err.message.includes('You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser')) {
|
|
83
|
+
const ruleName = err.message.match(/rule '([^']+)':/)?.[1];
|
|
84
|
+
let eslintConfigPathForError = `for ${projectName}`;
|
|
85
|
+
if (context.projectsConfigurations?.projects?.[projectName]?.root) {
|
|
86
|
+
const { root } = context.projectsConfigurations.projects[projectName];
|
|
87
|
+
eslintConfigPathForError = `\`${root}/.eslintrc.json\``;
|
|
88
|
+
}
|
|
89
|
+
console.error(`
|
|
90
|
+
Error: You have attempted to use ${ruleName ? `the lint rule ${ruleName}` : 'a lint rule'} which requires the full TypeScript type-checker to be available, but you do not have \`parserOptions.project\` configured to point at your project tsconfig.json files in the relevant TypeScript file "overrides" block of your project ESLint config ${eslintConfigPath || eslintConfigPathForError}
|
|
91
|
+
|
|
92
|
+
Please see https://nx.dev/guides/eslint for full guidance on how to resolve this issue.
|
|
93
|
+
`);
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// If some unexpected error, rethrow
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
if (lintResults.length === 0 && errorOnUnmatchedPattern) {
|
|
102
|
+
const ignoredPatterns = (await Promise.all(normalizedLintFilePatterns.map(async (pattern) => (await eslint.isPathIgnored(pattern)) ? pattern : null)))
|
|
103
|
+
.filter((pattern) => !!pattern)
|
|
104
|
+
.map((pattern) => `- '${pattern}'`);
|
|
105
|
+
if (ignoredPatterns.length) {
|
|
106
|
+
const ignoreSection = hasFlatConfig
|
|
107
|
+
? `'ignores' configuration`
|
|
108
|
+
: `'.eslintignore' file`;
|
|
109
|
+
throw new Error(`All files matching the following patterns are ignored:\n${ignoredPatterns.join('\n')}\n\nPlease check your ${ignoreSection}.`);
|
|
110
|
+
}
|
|
111
|
+
throw new Error('Invalid lint configuration. Nothing to lint. Please check your lint target pattern(s).');
|
|
112
|
+
}
|
|
113
|
+
// output fixes to disk, if applicable based on the options
|
|
114
|
+
await ESLint.outputFixes(lintResults);
|
|
115
|
+
// if quiet, only show errors
|
|
116
|
+
if (normalizedOptions.quiet) {
|
|
117
|
+
console.debug('Quiet mode enabled - filtering out warnings\n');
|
|
118
|
+
lintResults = ESLint.getErrorResults(lintResults);
|
|
119
|
+
}
|
|
120
|
+
const formatter = await eslint.loadFormatter(normalizedOptions.format);
|
|
121
|
+
const formattedResults = await formatter.format(lintResults);
|
|
122
|
+
if (normalizedOptions.outputFile) {
|
|
123
|
+
const pathToOutputFile = (0, devkit_1.joinPathFragments)(context.root, normalizedOptions.outputFile);
|
|
124
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(pathToOutputFile), { recursive: true });
|
|
125
|
+
(0, fs_1.writeFileSync)(pathToOutputFile, formattedResults);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
console.info(formattedResults);
|
|
129
|
+
}
|
|
130
|
+
const totals = getTotals(lintResults);
|
|
131
|
+
if (printInfo) {
|
|
132
|
+
outputPrintInfo(totals);
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
success: normalizedOptions.force ||
|
|
136
|
+
(totals.errors === 0 &&
|
|
137
|
+
(normalizedOptions.maxWarnings === -1 ||
|
|
138
|
+
totals.warnings <= normalizedOptions.maxWarnings)),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
exports.default = run;
|
|
142
|
+
function getTotals(lintResults) {
|
|
143
|
+
let errors = 0;
|
|
144
|
+
let warnings = 0;
|
|
145
|
+
let fixableErrors = 0;
|
|
146
|
+
let fixableWarnings = 0;
|
|
147
|
+
for (const result of lintResults) {
|
|
148
|
+
errors += result.errorCount || 0;
|
|
149
|
+
warnings += result.warningCount || 0;
|
|
150
|
+
fixableErrors += result.fixableErrorCount || 0;
|
|
151
|
+
fixableWarnings += result.fixableWarningCount || 0;
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
errors,
|
|
155
|
+
warnings,
|
|
156
|
+
fixableErrors,
|
|
157
|
+
fixableWarnings,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function pluralizedOutput(word, count) {
|
|
161
|
+
return `${count} ${word}${count === 1 ? '' : 's'}`;
|
|
162
|
+
}
|
|
163
|
+
function outputPrintInfo({ errors, warnings, fixableErrors, fixableWarnings, }) {
|
|
164
|
+
const total = warnings + errors;
|
|
165
|
+
const totalFixable = fixableErrors + fixableWarnings;
|
|
166
|
+
if (total <= 0) {
|
|
167
|
+
console.info('\u2714 All files pass linting\n');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
console.info(`\u2716 ${pluralizedOutput('problem', total)} (${pluralizedOutput('error', errors)}, ${pluralizedOutput('warning', warnings)})\n`);
|
|
171
|
+
if (totalFixable <= 0)
|
|
172
|
+
return;
|
|
173
|
+
console.info(` ${pluralizedOutput('error', fixableErrors)} and ${pluralizedOutput('warning', fixableWarnings)} are potentially fixable with the \`--fix\` option.\n`);
|
|
174
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { JsonObject } from '@angular-devkit/core';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
|
|
4
|
+
export interface Schema extends JsonObject {
|
|
5
|
+
eslintConfig: string | null;
|
|
6
|
+
lintFilePatterns: string[];
|
|
7
|
+
format: Formatter;
|
|
8
|
+
force: boolean;
|
|
9
|
+
silent: boolean;
|
|
10
|
+
fix: boolean;
|
|
11
|
+
cache: boolean;
|
|
12
|
+
noEslintrc: boolean;
|
|
13
|
+
outputFile: string | null;
|
|
14
|
+
cacheLocation: string | null;
|
|
15
|
+
maxWarnings: number;
|
|
16
|
+
quiet: boolean;
|
|
17
|
+
ignorePath: string | null;
|
|
18
|
+
hasTypeAwareRules: boolean;
|
|
19
|
+
cacheStrategy: 'content' | 'metadata' | null;
|
|
20
|
+
rulesdir: string[];
|
|
21
|
+
resolvePluginsRelativeTo: string | null;
|
|
22
|
+
reportUnusedDisableDirectives: Linter.StringSeverity | null;
|
|
23
|
+
printConfig?: string | null;
|
|
24
|
+
errorOnUnmatchedPattern?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type Formatter =
|
|
28
|
+
| 'stylish'
|
|
29
|
+
| 'compact'
|
|
30
|
+
| 'codeframe'
|
|
31
|
+
| 'unix'
|
|
32
|
+
| 'visualstudio'
|
|
33
|
+
| 'table'
|
|
34
|
+
| 'checkstyle'
|
|
35
|
+
| 'html'
|
|
36
|
+
| 'jslint-xml'
|
|
37
|
+
| 'json'
|
|
38
|
+
| 'json-with-metadata'
|
|
39
|
+
| 'junit'
|
|
40
|
+
| 'tap';
|