Skip to content

Commit 682eb7e

Browse files
authored
feat: add package scope-manager (typescript-eslint#1939)
1 parent 5c91bee commit 682eb7e

File tree

607 files changed

+45334
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

607 files changed

+45334
-54
lines changed

.cspell.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"**/*.{json,snap}",
1313
".cspell.json",
1414
"yarn.lock",
15-
".github/workflows/**"
15+
".github/workflows/**",
16+
".vscode/*.json"
1617
],
1718
"dictionaries": [
1819
"typescript",
@@ -57,6 +58,7 @@
5758
"ESLint",
5859
"ESLint's",
5960
"espree",
61+
"esrecurse",
6062
"estree",
6163
"IDE's",
6264
"IIFE",
@@ -75,11 +77,13 @@
7577
"Premade",
7678
"prettier's",
7779
"recurse",
80+
"redeclared",
7881
"reimplement",
7982
"resync",
8083
"ROADMAP",
8184
"ruleset",
8285
"rulesets",
86+
"serializers",
8387
"superset",
8488
"thenables",
8589
"transpiles",

.eslintrc.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ module.exports = {
5555
'@typescript-eslint/prefer-nullish-coalescing': 'error',
5656
'@typescript-eslint/prefer-optional-chain': 'error',
5757
'@typescript-eslint/unbound-method': 'off',
58+
'@typescript-eslint/prefer-as-const': 'error',
59+
'@typescript-eslint/no-unused-vars': [
60+
'warn',
61+
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
62+
],
5863

5964
// TODO - enable these new recommended rules
6065
'@typescript-eslint/no-floating-promises': 'off',
@@ -224,5 +229,18 @@ module.exports = {
224229
'no-console': 'off',
225230
},
226231
},
232+
// generated files
233+
{
234+
files: [
235+
'packages/scope-manager/src/lib/*.ts',
236+
'packages/eslint-plugin/src/configs/*.ts',
237+
],
238+
rules: {
239+
// allow console logs in tools and tests
240+
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
241+
'@typescript-eslint/internal/no-typescript-default-import': 'off',
242+
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
243+
},
244+
},
227245
],
228246
};

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55
branches:
66
- master
7-
# TODO - delete this before merging v3 into master
8-
- v3
97
pull_request:
108
branches:
119
- '**'
@@ -103,6 +101,12 @@ jobs:
103101
env:
104102
CI: true
105103

104+
- name: Run unit tests for scope-manager
105+
run: yarn test
106+
working-directory: packages/scope-manager
107+
env:
108+
CI: true
109+
106110
- name: Run unit tests for experimental-utils
107111
run: yarn test
108112
working-directory: packages/experimental-utils
@@ -269,6 +273,12 @@ jobs:
269273
env:
270274
CI: true
271275

276+
- name: Run unit tests for scope-manager
277+
run: yarn test
278+
working-directory: packages/scope-manager
279+
env:
280+
CI: true
281+
272282
- name: Run unit tests for experimental-utils
273283
run: yarn test
274284
working-directory: packages/experimental-utils

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
**/tests/fixtures/**/*
2+
!packages/scope-manager/tests/fixtures/**/*
23
**/tests/fixture-project/**/*
34
**/dist
45
**/coverage

.vscode/extensions.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"recommendations": [
3-
"esbenp.prettier-vscode",
3+
"davidanson.vscode-markdownlint",
44
"dbaeumer.vscode-eslint",
55
"editorconfig.editorconfig",
6+
"esbenp.prettier-vscode",
67
"streetsidesoftware.code-spell-checker",
7-
"davidanson.vscode-markdownlint"
8+
"tlent.jest-snapshot-language-support"
89
],
910
"unwantedRecommendations": ["hookyqr.beautify", "dbaeumer.jshint"]
1011
}

.vscode/launch.json

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"${workspaceFolder}/packages/types/dist/index.js",
3333
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
3434
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
35+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
36+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
3537
],
3638
},
3739
{
@@ -62,6 +64,8 @@
6264
"${workspaceFolder}/packages/types/dist/index.js",
6365
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
6466
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
67+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
68+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
6569
],
6670
},
6771
{
@@ -92,6 +96,8 @@
9296
"${workspaceFolder}/packages/types/dist/index.js",
9397
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
9498
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
99+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
100+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
95101
],
96102
},
97103
{
@@ -122,6 +128,8 @@
122128
"${workspaceFolder}/packages/types/dist/index.js",
123129
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
124130
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
131+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
132+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
125133
],
126134
},
127135
{
@@ -152,7 +160,41 @@
152160
"${workspaceFolder}/packages/types/dist/index.js",
153161
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
154162
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
163+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
164+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
155165
],
156-
}
166+
},
167+
{
168+
"type": "node",
169+
"request": "launch",
170+
"name": "Run currently opened scope-manager test",
171+
"cwd": "${workspaceFolder}/packages/scope-manager/",
172+
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
173+
"args": [
174+
"--runInBand",
175+
"--no-cache",
176+
"--no-coverage",
177+
"${fileBasename}"
178+
],
179+
"sourceMaps": true,
180+
"console": "integratedTerminal",
181+
"internalConsoleOptions": "neverOpen",
182+
"skipFiles": [
183+
"${workspaceFolder}/packages/experimental-utils/src/index.ts",
184+
"${workspaceFolder}/packages/experimental-utils/dist/index.js",
185+
"${workspaceFolder}/packages/experimental-utils/src/ts-estree.ts",
186+
"${workspaceFolder}/packages/experimental-utils/dist/ts-estree.js",
187+
"${workspaceFolder}/packages/parser/src/index.ts",
188+
"${workspaceFolder}/packages/parser/dist/index.js",
189+
"${workspaceFolder}/packages/typescript-estree/src/index.ts",
190+
"${workspaceFolder}/packages/typescript-estree/dist/index.js",
191+
"${workspaceFolder}/packages/types/src/index.ts",
192+
"${workspaceFolder}/packages/types/dist/index.js",
193+
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
194+
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
195+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
196+
"${workspaceFolder}/packages/scope-manager/dist/index.js",
197+
],
198+
},
157199
]
158200
}

.vscode/settings.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,21 @@
1818
"javascript.preferences.quoteStyle": "single",
1919
"typescript.preferences.quoteStyle": "single",
2020
"editor.defaultFormatter": "esbenp.prettier-vscode",
21+
22+
// make the .shot files from jest-specific-snapshot act like normal snapshots
23+
"files.associations": {
24+
"*.shot": "jest-snapshot"
25+
},
26+
"vsicons.associations.files": [
27+
{
28+
"icon": "jest_snapshot",
29+
"extensions": [
30+
".ts.shot",
31+
".tsx.shot",
32+
".js.shot",
33+
".jsx.shot",
34+
],
35+
"extends": "jest_snapshot"
36+
},
37+
],
2138
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"@types/jest": "^25.2.1",
7373
"@types/node": "^13.13.5",
7474
"@types/prettier": "^2.0.0",
75+
"@types/rimraf": "^3.0.0",
7576
"all-contributors-cli": "^6.14.2",
7677
"cspell": "^4.0.61",
7778
"cz-conventional-changelog": "^3.2.0",

packages/eslint-plugin-internal/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
// @ts-check
4+
/** @type {import('@jest/types').Config.InitialOptions} */
35
module.exports = {
46
globals: {
57
'ts-jest': {

packages/eslint-plugin-tslint/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
// @ts-check
4+
/** @type {import('@jest/types').Config.InitialOptions} */
35
module.exports = {
46
globals: {
57
'ts-jest': {

packages/eslint-plugin/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
// @ts-check
4+
/** @type {import('@jest/types').Config.InitialOptions} */
35
module.exports = {
46
globals: {
57
'ts-jest': {

packages/eslint-plugin/src/configs/all.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// YOU CAN REGENERATE IT USING yarn generate:configs
4+
15
export = {
26
extends: ['./configs/base', './configs/eslint-recommended'],
37
rules: {

packages/eslint-plugin/src/configs/base.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// YOU CAN REGENERATE IT USING yarn generate:configs
4+
15
export = {
26
parser: '@typescript-eslint/parser',
37
parserOptions: { sourceType: 'module' },

packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// YOU CAN REGENERATE IT USING yarn generate:configs
4+
15
export = {
26
extends: ['./configs/base', './configs/eslint-recommended'],
37
rules: {

packages/eslint-plugin/src/configs/recommended.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// THIS CODE WAS AUTOMATICALLY GENERATED
2+
// DO NOT EDIT THIS CODE BY HAND
3+
// YOU CAN REGENERATE IT USING yarn generate:configs
4+
15
export = {
26
extends: ['./configs/base', './configs/eslint-recommended'],
37
rules: {

packages/eslint-plugin/tools/generate-configs.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import path from 'path';
55
import { format, resolveConfig } from 'prettier';
66
import rules from '../src/rules';
77

8+
function addAutoGeneratedComment(code: string): string {
9+
return [
10+
'// THIS CODE WAS AUTOMATICALLY GENERATED',
11+
'// DO NOT EDIT THIS CODE BY HAND',
12+
'// YOU CAN REGENERATE IT USING yarn generate:configs',
13+
'',
14+
code,
15+
].join('\n');
16+
}
17+
818
const prettierConfig = resolveConfig.sync(__dirname);
919

1020
interface LinterConfigRules {
@@ -117,8 +127,9 @@ function reducer<TMessageIds extends string>(
117127
* Helper function writes configuration.
118128
*/
119129
function writeConfig(config: LinterConfig, filePath: string): void {
130+
// note: we use `export =` because ESLint will import these configs via a commonjs import
120131
const code = `export = ${JSON.stringify(config)};`;
121-
const configStr = format(code, {
132+
const configStr = format(addAutoGeneratedComment(code), {
122133
parser: 'typescript',
123134
...prettierConfig,
124135
});

packages/experimental-utils/jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
// @ts-check
4+
/** @type {import('@jest/types').Config.InitialOptions} */
35
module.exports = {
46
globals: {
57
'ts-jest': {

packages/scope-manager/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 TypeScript ESLint and other contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy