Skip to content

Commit

Permalink
feat: add package scope-manager (#1939)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Jun 29, 2020
1 parent 5c91bee commit 682eb7e
Show file tree
Hide file tree
Showing 607 changed files with 45,334 additions and 54 deletions.
6 changes: 5 additions & 1 deletion .cspell.json
Expand Up @@ -12,7 +12,8 @@
"**/*.{json,snap}",
".cspell.json",
"yarn.lock",
".github/workflows/**"
".github/workflows/**",
".vscode/*.json"
],
"dictionaries": [
"typescript",
Expand Down Expand Up @@ -57,6 +58,7 @@
"ESLint",
"ESLint's",
"espree",
"esrecurse",
"estree",
"IDE's",
"IIFE",
Expand All @@ -75,11 +77,13 @@
"Premade",
"prettier's",
"recurse",
"redeclared",
"reimplement",
"resync",
"ROADMAP",
"ruleset",
"rulesets",
"serializers",
"superset",
"thenables",
"transpiles",
Expand Down
18 changes: 18 additions & 0 deletions .eslintrc.js
Expand Up @@ -55,6 +55,11 @@ module.exports = {
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/no-unused-vars': [
'warn',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
],

// TODO - enable these new recommended rules
'@typescript-eslint/no-floating-promises': 'off',
Expand Down Expand Up @@ -224,5 +229,18 @@ module.exports = {
'no-console': 'off',
},
},
// generated files
{
files: [
'packages/scope-manager/src/lib/*.ts',
'packages/eslint-plugin/src/configs/*.ts',
],
rules: {
// allow console logs in tools and tests
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
'@typescript-eslint/internal/no-typescript-default-import': 'off',
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
},
},
],
};
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- master
# TODO - delete this before merging v3 into master
- v3
pull_request:
branches:
- '**'
Expand Down Expand Up @@ -103,6 +101,12 @@ jobs:
env:
CI: true

- name: Run unit tests for scope-manager
run: yarn test
working-directory: packages/scope-manager
env:
CI: true

- name: Run unit tests for experimental-utils
run: yarn test
working-directory: packages/experimental-utils
Expand Down Expand Up @@ -269,6 +273,12 @@ jobs:
env:
CI: true

- name: Run unit tests for scope-manager
run: yarn test
working-directory: packages/scope-manager
env:
CI: true

- name: Run unit tests for experimental-utils
run: yarn test
working-directory: packages/experimental-utils
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
@@ -1,4 +1,5 @@
**/tests/fixtures/**/*
!packages/scope-manager/tests/fixtures/**/*
**/tests/fixture-project/**/*
**/dist
**/coverage
Expand Down
5 changes: 3 additions & 2 deletions .vscode/extensions.json
@@ -1,10 +1,11 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker",
"davidanson.vscode-markdownlint"
"tlent.jest-snapshot-language-support"
],
"unwantedRecommendations": ["hookyqr.beautify", "dbaeumer.jshint"]
}
44 changes: 43 additions & 1 deletion .vscode/launch.json
Expand Up @@ -32,6 +32,8 @@
"${workspaceFolder}/packages/types/dist/index.js",
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},
{
Expand Down Expand Up @@ -62,6 +64,8 @@
"${workspaceFolder}/packages/types/dist/index.js",
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},
{
Expand Down Expand Up @@ -92,6 +96,8 @@
"${workspaceFolder}/packages/types/dist/index.js",
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},
{
Expand Down Expand Up @@ -122,6 +128,8 @@
"${workspaceFolder}/packages/types/dist/index.js",
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},
{
Expand Down Expand Up @@ -152,7 +160,41 @@
"${workspaceFolder}/packages/types/dist/index.js",
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
}
},
{
"type": "node",
"request": "launch",
"name": "Run currently opened scope-manager test",
"cwd": "${workspaceFolder}/packages/scope-manager/",
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
"args": [
"--runInBand",
"--no-cache",
"--no-coverage",
"${fileBasename}"
],
"sourceMaps": true,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"skipFiles": [
"${workspaceFolder}/packages/experimental-utils/src/index.ts",
"${workspaceFolder}/packages/experimental-utils/dist/index.js",
"${workspaceFolder}/packages/experimental-utils/src/ts-estree.ts",
"${workspaceFolder}/packages/experimental-utils/dist/ts-estree.js",
"${workspaceFolder}/packages/parser/src/index.ts",
"${workspaceFolder}/packages/parser/dist/index.js",
"${workspaceFolder}/packages/typescript-estree/src/index.ts",
"${workspaceFolder}/packages/typescript-estree/dist/index.js",
"${workspaceFolder}/packages/types/src/index.ts",
"${workspaceFolder}/packages/types/dist/index.js",
"${workspaceFolder}/packages/visitor-keys/src/index.ts",
"${workspaceFolder}/packages/visitor-keys/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
"${workspaceFolder}/packages/scope-manager/dist/index.js",
],
},
]
}
17 changes: 17 additions & 0 deletions .vscode/settings.json
Expand Up @@ -18,4 +18,21 @@
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"editor.defaultFormatter": "esbenp.prettier-vscode",

// make the .shot files from jest-specific-snapshot act like normal snapshots
"files.associations": {
"*.shot": "jest-snapshot"
},
"vsicons.associations.files": [
{
"icon": "jest_snapshot",
"extensions": [
".ts.shot",
".tsx.shot",
".js.shot",
".jsx.shot",
],
"extends": "jest_snapshot"
},
],
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -72,6 +72,7 @@
"@types/jest": "^25.2.1",
"@types/node": "^13.13.5",
"@types/prettier": "^2.0.0",
"@types/rimraf": "^3.0.0",
"all-contributors-cli": "^6.14.2",
"cspell": "^4.0.61",
"cz-conventional-changelog": "^3.2.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin-internal/jest.config.js
@@ -1,5 +1,7 @@
'use strict';

// @ts-check
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
globals: {
'ts-jest': {
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin-tslint/jest.config.js
@@ -1,5 +1,7 @@
'use strict';

// @ts-check
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
globals: {
'ts-jest': {
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/jest.config.js
@@ -1,5 +1,7 @@
'use strict';

// @ts-check
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
globals: {
'ts-jest': {
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin/src/configs/all.ts
@@ -1,3 +1,7 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:configs

export = {
extends: ['./configs/base', './configs/eslint-recommended'],
rules: {
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin/src/configs/base.ts
@@ -1,3 +1,7 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:configs

export = {
parser: '@typescript-eslint/parser',
parserOptions: { sourceType: 'module' },
Expand Down
@@ -1,3 +1,7 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:configs

export = {
extends: ['./configs/base', './configs/eslint-recommended'],
rules: {
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin/src/configs/recommended.ts
@@ -1,3 +1,7 @@
// THIS CODE WAS AUTOMATICALLY GENERATED
// DO NOT EDIT THIS CODE BY HAND
// YOU CAN REGENERATE IT USING yarn generate:configs

export = {
extends: ['./configs/base', './configs/eslint-recommended'],
rules: {
Expand Down
13 changes: 12 additions & 1 deletion packages/eslint-plugin/tools/generate-configs.ts
Expand Up @@ -5,6 +5,16 @@ import path from 'path';
import { format, resolveConfig } from 'prettier';
import rules from '../src/rules';

function addAutoGeneratedComment(code: string): string {
return [
'// THIS CODE WAS AUTOMATICALLY GENERATED',
'// DO NOT EDIT THIS CODE BY HAND',
'// YOU CAN REGENERATE IT USING yarn generate:configs',
'',
code,
].join('\n');
}

const prettierConfig = resolveConfig.sync(__dirname);

interface LinterConfigRules {
Expand Down Expand Up @@ -117,8 +127,9 @@ function reducer<TMessageIds extends string>(
* Helper function writes configuration.
*/
function writeConfig(config: LinterConfig, filePath: string): void {
// note: we use `export =` because ESLint will import these configs via a commonjs import
const code = `export = ${JSON.stringify(config)};`;
const configStr = format(code, {
const configStr = format(addAutoGeneratedComment(code), {
parser: 'typescript',
...prettierConfig,
});
Expand Down
2 changes: 2 additions & 0 deletions packages/experimental-utils/jest.config.js
@@ -1,5 +1,7 @@
'use strict';

// @ts-check
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
globals: {
'ts-jest': {
Expand Down
21 changes: 21 additions & 0 deletions packages/scope-manager/LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 TypeScript ESLint and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

0 comments on commit 682eb7e

Please sign in to comment.