From 92f21d48140d27120ae5a6656390191f00c93f00 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 27 Oct 2021 22:15:32 -0700 Subject: [PATCH 01/10] chore: make GH show `.shot` files as jest snapshots --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index 73968f2a6144..d46a42b7fc44 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,3 +5,6 @@ *.ts eol=lf *.tsx eol=lf *.yml eol=lf + +# force github to treat out custom jest snapshot extension as normal jest snapshots +*.shot linguist-language=Jest-Snapshot From d8df233cc05058b9b8dae9ea863a894b332bfa2a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 30 Oct 2021 14:16:15 -0400 Subject: [PATCH 02/10] chore: mention needing an issue for a PR in CONTRIBUTING.md (#4071) --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f742bdd75e93..9af92775588b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,6 +30,8 @@ Please refrain from commenting on `master` commits. Commit comments are not sear ## Pull Requests +> With the exception of extremely minor documentation typos, **only send pull requests that resolve open issues**. + Anyone is free to help us build and maintain this project. If you see an issue that needs working on because it's important to you, comment on the issue to help make sure that nobody else works on it at the same time, and then start working. Developing in this repo is easy: From f3021c94460e8d06e4169335bcc1a23854531f2a Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 31 Oct 2021 12:11:55 +1300 Subject: [PATCH 03/10] fix(experimental-utils): add `name` property to test case interface (#4067) --- packages/experimental-utils/src/ts-eslint/RuleTester.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/experimental-utils/src/ts-eslint/RuleTester.ts b/packages/experimental-utils/src/ts-eslint/RuleTester.ts index 9a255b242070..2049d9f90e70 100644 --- a/packages/experimental-utils/src/ts-eslint/RuleTester.ts +++ b/packages/experimental-utils/src/ts-eslint/RuleTester.ts @@ -9,6 +9,10 @@ import { } from './Rule'; interface ValidTestCase> { + /** + * Name for the test case. + */ + readonly name?: string; /** * Code for the test case. */ From 18104cd0204767f43e18a9f0e8b1956db6155b47 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Sun, 31 Oct 2021 20:17:18 -0700 Subject: [PATCH 04/10] test: rework the integration tests to not use docker (#4078) --- .eslintrc.js | 6 +- .github/workflows/ci.yml | 43 ----- package.json | 5 +- packages/typescript-estree/package.json | 2 +- .../tests/lib/convert.test.ts | 2 +- tests/integration/README.md | 31 ++-- tests/integration/docker-compose.yml | 166 ------------------ .../fixtures/eslint-v6/.eslintrc.js | 6 +- .../integration/fixtures/eslint-v6/Dockerfile | 17 -- .../fixtures/eslint-v6/package.json | 5 + tests/integration/fixtures/eslint-v6/test.sh | 26 --- .../fixtures/markdown/.eslintrc.js | 8 +- .../integration/fixtures/markdown/Dockerfile | 17 -- .../fixtures/markdown/package.json | 5 + tests/integration/fixtures/markdown/test.sh | 28 --- .../.eslintrc.js | 6 +- .../Dockerfile | 17 -- .../package.json | 3 + .../test.sh | 25 --- .../.eslintrc.js | 8 +- .../Dockerfile | 17 -- .../package.json | 5 + .../test.js.snap | 49 ------ .../test.sh | 26 --- .../integration/fixtures/vue-jsx/.eslintrc.js | 6 +- tests/integration/fixtures/vue-jsx/Dockerfile | 17 -- .../integration/fixtures/vue-jsx/package.json | 8 + tests/integration/fixtures/vue-jsx/test.sh | 30 ---- .../integration/fixtures/vue-sfc/.eslintrc.js | 6 +- tests/integration/fixtures/vue-sfc/Dockerfile | 17 -- .../integration/fixtures/vue-sfc/package.json | 8 + tests/integration/fixtures/vue-sfc/test.sh | 30 ---- tests/integration/integration-test-base.ts | 138 +++++++++++++++ tests/integration/jest.config.js | 34 ++++ tests/integration/pack-packages.ts | 52 ++++++ tests/integration/run-all-tests.sh | 23 --- .../__snapshots__/eslint-v6.test.ts.snap} | 4 +- .../__snapshots__/markdown.test.ts.snap} | 4 +- ...ded-does-not-require-program.test.ts.snap} | 44 ++--- ...t-and-tslint-plugins-together.test.ts.snap | 26 +++ .../__snapshots__/vue-jsx.test.ts.snap} | 4 +- .../__snapshots__/vue-sfc.test.ts.snap} | 108 +++++++----- tests/integration/tests/eslint-v6.test.ts | 3 + tests/integration/tests/markdown.test.ts | 3 + ...commended-does-not-require-program.test.ts | 3 + ...script-and-tslint-plugins-together.test.ts | 3 + tests/integration/tests/vue-jsx.test.ts | 3 + tests/integration/tests/vue-sfc.test.ts | 3 + tests/integration/tsconfig.json | 10 ++ tests/integration/utils/.eslintrc.js | 5 - .../utils/generate-package-json.js | 21 --- .../utils/jest-snapshot-resolver.js | 19 -- tests/integration/utils/jsconfig.json | 7 - tsconfig.eslint.json | 7 +- yarn.lock | 26 ++- 55 files changed, 453 insertions(+), 742 deletions(-) delete mode 100644 tests/integration/docker-compose.yml delete mode 100644 tests/integration/fixtures/eslint-v6/Dockerfile create mode 100644 tests/integration/fixtures/eslint-v6/package.json delete mode 100755 tests/integration/fixtures/eslint-v6/test.sh delete mode 100644 tests/integration/fixtures/markdown/Dockerfile create mode 100644 tests/integration/fixtures/markdown/package.json delete mode 100755 tests/integration/fixtures/markdown/test.sh delete mode 100644 tests/integration/fixtures/recommended-does-not-require-program/Dockerfile create mode 100644 tests/integration/fixtures/recommended-does-not-require-program/package.json delete mode 100755 tests/integration/fixtures/recommended-does-not-require-program/test.sh delete mode 100644 tests/integration/fixtures/typescript-and-tslint-plugins-together/Dockerfile create mode 100644 tests/integration/fixtures/typescript-and-tslint-plugins-together/package.json delete mode 100644 tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap delete mode 100755 tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh delete mode 100644 tests/integration/fixtures/vue-jsx/Dockerfile create mode 100644 tests/integration/fixtures/vue-jsx/package.json delete mode 100755 tests/integration/fixtures/vue-jsx/test.sh delete mode 100644 tests/integration/fixtures/vue-sfc/Dockerfile create mode 100644 tests/integration/fixtures/vue-sfc/package.json delete mode 100755 tests/integration/fixtures/vue-sfc/test.sh create mode 100644 tests/integration/integration-test-base.ts create mode 100644 tests/integration/jest.config.js create mode 100644 tests/integration/pack-packages.ts delete mode 100755 tests/integration/run-all-tests.sh rename tests/integration/{fixtures/eslint-v6/test.js.snap => tests/__snapshots__/eslint-v6.test.ts.snap} (85%) rename tests/integration/{fixtures/markdown/test.js.snap => tests/__snapshots__/markdown.test.ts.snap} (98%) rename tests/integration/{fixtures/recommended-does-not-require-program/test.js.snap => tests/__snapshots__/recommended-does-not-require-program.test.ts.snap} (65%) create mode 100644 tests/integration/tests/__snapshots__/typescript-and-tslint-plugins-together.test.ts.snap rename tests/integration/{fixtures/vue-jsx/test.js.snap => tests/__snapshots__/vue-jsx.test.ts.snap} (96%) rename tests/integration/{fixtures/vue-sfc/test.js.snap => tests/__snapshots__/vue-sfc.test.ts.snap} (51%) create mode 100644 tests/integration/tests/eslint-v6.test.ts create mode 100644 tests/integration/tests/markdown.test.ts create mode 100644 tests/integration/tests/recommended-does-not-require-program.test.ts create mode 100644 tests/integration/tests/typescript-and-tslint-plugins-together.test.ts create mode 100644 tests/integration/tests/vue-jsx.test.ts create mode 100644 tests/integration/tests/vue-sfc.test.ts create mode 100644 tests/integration/tsconfig.json delete mode 100644 tests/integration/utils/.eslintrc.js delete mode 100644 tests/integration/utils/generate-package-json.js delete mode 100644 tests/integration/utils/jest-snapshot-resolver.js delete mode 100644 tests/integration/utils/jsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js index cfd40c184f1b..afe9b3b78d93 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,8 +22,8 @@ module.exports = { sourceType: 'module', project: [ './tsconfig.eslint.json', - './tests/integration/utils/jsconfig.json', './packages/*/tsconfig.json', + './tests/integration/tsconfig.json', ], allowAutomaticSingleRunInference: true, tsconfigRootDir: __dirname, @@ -175,12 +175,16 @@ module.exports = { 'packages/*/tests/**/spec.ts', 'packages/*/tests/**/test.ts', 'packages/parser/tests/**/*.ts', + 'tests/integration/**/*.test.ts', + 'tests/integration/integration-test-base.ts', + 'tests/integration/pack-packages.ts', ], env: { 'jest/globals': true, }, rules: { '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-return': 'off', 'eslint-plugin/no-identical-tests': 'error', diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5acbec2c9c79..3e25c8d3eab0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -343,46 +343,3 @@ jobs: run: npx lerna publish --loglevel=verbose --canary --exact --force-publish --yes env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - publish_canary_version_v5: - name: Publish the latest code as a canary version - runs-on: ubuntu-latest - needs: [typecheck, test_on_primary_node_version, unit_tests_on_other_node_versions, linting_and_style, integration_tests] - if: github.repository == 'typescript-eslint/typescript-eslint' && github.ref == 'refs/heads/v5' - steps: - - uses: actions/checkout@v2 - # Fetch all history for all tags and branches in this job because lerna needs it - - run: | - git fetch --prune --unshallow - - - name: Use Node.js ${{ env.PRIMARY_NODE_VERSION }} - uses: actions/setup-node@v1 - with: - node-version: ${{ env.PRIMARY_NODE_VERSION }} - registry-url: https://registry.npmjs.org/ - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - - uses: actions/cache@v2 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Install dependencies - run: | - yarn --ignore-engines --frozen-lockfile --ignore-scripts - yarn check-clean-workspace-after-install - - - name: Build - run: | - yarn build - - - name: Publish all packages to npm - run: npx lerna publish premajor --loglevel=verbose --canary --exact --force-publish --yes --dist-tag rc-v5 - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index 9a5701855291..3fcacac8fda6 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "pre-commit": "yarn lint-staged", "pre-push": "yarn check-format", "test": "nx run-many --target=test --all --parallel", - "test-integration": "./tests/integration/run-all-tests.sh", + "test-integration": "yarn jest -c ./tests/integration/jest.config.js", "test-kill-integration-containers": "docker-compose -f tests/integration/docker-compose.yml down -v --rmi local", "typecheck": "nx run-many --target=typecheck --all --parallel" }, @@ -90,6 +90,7 @@ "@types/jest-specific-snapshot": "^0.5.5", "@types/lodash": "^4.14.176", "@types/marked": "^3.0.2", + "@types/ncp": "^2.0.5", "@types/node": "^16.11.4", "@types/prettier": "^2.3.2", "@types/rimraf": "^3.0.2", @@ -114,10 +115,12 @@ "lint-staged": "^11.1.2", "make-dir": "^3.1.0", "markdownlint-cli": "^0.29.0", + "ncp": "^2.0.0", "node-fetch": "^3.0.0", "prettier": "2.4.1", "pretty-format": "^27.3.1", "rimraf": "^3.0.2", + "tmp": "^0.2.1", "ts-jest": "^27.0.5", "ts-node": "^10.4.0", "tslint": "^6.1.3", diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index dd42cfcc7a3c..a5717e134417 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -63,7 +63,7 @@ "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", - "tmp": "^0.2.1", + "tmp": "*", "typescript": "*" }, "peerDependenciesMeta": { diff --git a/packages/typescript-estree/tests/lib/convert.test.ts b/packages/typescript-estree/tests/lib/convert.test.ts index 277063b9d8cb..ad60019b2004 100644 --- a/packages/typescript-estree/tests/lib/convert.test.ts +++ b/packages/typescript-estree/tests/lib/convert.test.ts @@ -1,5 +1,5 @@ // deeplyCopy is private internal -/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-call */ +/* eslint-disable @typescript-eslint/no-explicit-any */ import * as ts from 'typescript'; import type { TSNode } from '../../src'; import { Converter } from '../../src/convert'; diff --git a/tests/integration/README.md b/tests/integration/README.md index a1f39ca6eb21..689dca292110 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -2,19 +2,30 @@ We have a set of integration tests defined in this project to help ensure we don't inadvertently break downstream packages that depend on us. -These tests are setup to run within docker containers to ensure that each test is completely isolated; we don't want them to affect our local environment, and similarly we don't want them to be effected by our local environment. +These tests are setup to run within temporary folders to ensure that each test is isolated from the project. ## Adding a new integration test -1. [Install docker for your platform](https://docs.docker.com/v17.09/engine/installation/#supported-platforms). 1. Add a new folder in `/tests/integration/fixtures` -1. Add a `.eslintrc.yml`, and a `tsconfig.json` to your folder, with the config required. +1. Add a `package.json` to your folder. +1. List the required dependencies under `devDependencies`. + - Use `latest` for the dependency to ensure we are testing against the newest versions of the package. + - If you have no dependencies, just add `"devDependencies": {}`. +1. Add a `.eslintrc.js`, and a `tsconfig.json` to your folder, with all of the config required. 1. Create the necessary files to test the integration. -1. Copy+paste the `Dockerfile` from an existing fixture (they are all the same). -1. Copy+paste the `test.sh` from an existing fixture, and adjust the `eslint` command as required. -1. Add a new entry to `docker-compose.yml` by copy+pasting an existing section, and changing the name to match your new folder. -1. Add a new entry to `run-all-tests.sh` by copy+pasting an existing command, and changing the name to match your new folder. -1. Run your integration test by running the single command you copied in the previous step. - - If your test finishes successfully, a `test.js.snap` will be created. + - Your test should have a lint error in it in an appropriate location. + This is so that we can be certain the setup actually works correctly. +1. Add a test to `/tests/integration/tests` named the same as your folder. +1. Paste the following content into your test: -If you run your test and see the test fail with `Cannot find module './lint-output.json' from 'test.js'`, this means that ESLint errored whilst attempting to run the lint command. + ```ts + import { integrationTest } from '../integration-test-base'; + + integrationTest( + __filename, + '*.ts' /* UPDATE THIS TO THE EXTENSION(s) TO LINT */, + ); + ``` + +1. Run your integration test with `yarn test-integration ./tests/integration/tests/your-file.test.ts` + - This will generate your snapshot output for the lint run which is a JSON representation of your ESLint run. diff --git a/tests/integration/docker-compose.yml b/tests/integration/docker-compose.yml deleted file mode 100644 index b1df8c206699..000000000000 --- a/tests/integration/docker-compose.yml +++ /dev/null @@ -1,166 +0,0 @@ -version: '3' - -services: - typescript-and-tslint-plugins-together: - build: ./fixtures/typescript-and-tslint-plugins-together - container_name: 'typescript-and-tslint-plugins-together' - volumes: - # Runtime link to the relevant built @typescript-eslint packages and integration test utils, - # but apply an empty volume for the package tests, we don't need those. - - ../../package.json/:/usr/root-package.json - - ./utils/:/usr/utils - - ../../packages/parser/:/usr/parser - - /usr/parser/tests - - ../../packages/typescript-estree/:/usr/typescript-estree - - /usr/typescript-estree/tests - - ../../packages/experimental-utils/:/usr/experimental-utils - - /usr/experimental-utils/tests - - ../../packages/eslint-plugin/:/usr/eslint-plugin - - /usr/eslint-plugin/tests - - ../../packages/eslint-plugin-tslint/:/usr/eslint-plugin-tslint - - /usr/eslint-plugin-tslint/tests - - ../../packages/types/:/usr/types - - /usr/types/tests - - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/visitor-keys/tests - - ../../packages/scope-manager/:/usr/scope-manager - - /usr/scope-manager/tests - - ../../packages/ast-spec/:/usr/ast-spec - - /usr/ast-spec/tests - # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - - ./fixtures/typescript-and-tslint-plugins-together:/usr/linked - - vue-sfc: - build: ./fixtures/vue-sfc - container_name: 'vue-sfc' - volumes: - # Runtime link to the relevant built @typescript-eslint packages and integration test utils, - # but apply an empty volume for the package tests, we don't need those. - - ../../package.json/:/usr/root-package.json - - ./utils/:/usr/utils - - ../../packages/parser/:/usr/parser - - /usr/parser/tests - - ../../packages/typescript-estree/:/usr/typescript-estree - - /usr/typescript-estree/tests - - ../../packages/experimental-utils/:/usr/experimental-utils - - /usr/experimental-utils/tests - - ../../packages/eslint-plugin/:/usr/eslint-plugin - - /usr/eslint-plugin/tests - - ../../packages/types/:/usr/types - - /usr/types/tests - - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/visitor-keys/tests - - ../../packages/scope-manager/:/usr/scope-manager - - /usr/scope-manager/tests - - ../../packages/ast-spec/:/usr/ast-spec - - /usr/ast-spec/tests - # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - - ./fixtures/vue-sfc:/usr/linked - - vue-jsx: - build: ./fixtures/vue-jsx - container_name: 'vue-jsx' - volumes: - # Runtime link to the relevant built @typescript-eslint packages and integration test utils, - # but apply an empty volume for the package tests, we don't need those. - - ../../package.json/:/usr/root-package.json - - ./utils/:/usr/utils - - ../../packages/parser/:/usr/parser - - /usr/parser/tests - - ../../packages/typescript-estree/:/usr/typescript-estree - - /usr/typescript-estree/tests - - ../../packages/experimental-utils/:/usr/experimental-utils - - /usr/experimental-utils/tests - - ../../packages/eslint-plugin/:/usr/eslint-plugin - - /usr/eslint-plugin/tests - - ../../packages/types/:/usr/types - - /usr/types/tests - - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/visitor-keys/tests - - ../../packages/scope-manager/:/usr/scope-manager - - /usr/scope-manager/tests - - ../../packages/ast-spec/:/usr/ast-spec - - /usr/ast-spec/tests - # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - - ./fixtures/vue-jsx:/usr/linked - - recommended-does-not-require-program: - build: ./fixtures/recommended-does-not-require-program - container_name: 'recommended-does-not-require-program' - volumes: - # Runtime link to the relevant built @typescript-eslint packages and integration test utils, - # but apply an empty volume for the package tests, we don't need those. - - ../../package.json/:/usr/root-package.json - - ./utils/:/usr/utils - - ../../packages/parser/:/usr/parser - - /usr/parser/tests - - ../../packages/typescript-estree/:/usr/typescript-estree - - /usr/typescript-estree/tests - - ../../packages/experimental-utils/:/usr/experimental-utils - - /usr/experimental-utils/tests - - ../../packages/eslint-plugin/:/usr/eslint-plugin - - /usr/eslint-plugin/tests - - ../../packages/types/:/usr/types - - /usr/types/tests - - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/visitor-keys/tests - - ../../packages/scope-manager/:/usr/scope-manager - - /usr/scope-manager/tests - - ../../packages/ast-spec/:/usr/ast-spec - - /usr/ast-spec/tests - # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - - ./fixtures/recommended-does-not-require-program:/usr/linked - - markdown: - build: ./fixtures/markdown - container_name: 'markdown' - volumes: - # Runtime link to the relevant built @typescript-eslint packages and integration test utils, - # but apply an empty volume for the package tests, we don't need those. - - ../../package.json/:/usr/root-package.json - - ./utils/:/usr/utils - - ../../packages/parser/:/usr/parser - - /usr/parser/tests - - ../../packages/typescript-estree/:/usr/typescript-estree - - /usr/typescript-estree/tests - - ../../packages/experimental-utils/:/usr/experimental-utils - - /usr/experimental-utils/tests - - ../../packages/eslint-plugin/:/usr/eslint-plugin - - /usr/eslint-plugin/tests - - ../../packages/types/:/usr/types - - /usr/types/tests - - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/visitor-keys/tests - - ../../packages/scope-manager/:/usr/scope-manager - - /usr/scope-manager/tests - - ../../packages/ast-spec/:/usr/ast-spec - - /usr/ast-spec/tests - # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - - ./fixtures/markdown:/usr/linked - - eslint-v6: - build: ./fixtures/eslint-v6 - container_name: 'eslint-v6' - volumes: - # Runtime link to the relevant built @typescript-eslint packages and integration test utils, - # but apply an empty volume for the package tests, we don't need those. - - ../../package.json/:/usr/root-package.json - - ./utils/:/usr/utils - - ../../packages/parser/:/usr/parser - - /usr/parser/tests - - ../../packages/typescript-estree/:/usr/typescript-estree - - /usr/typescript-estree/tests - - ../../packages/experimental-utils/:/usr/experimental-utils - - /usr/experimental-utils/tests - - ../../packages/eslint-plugin/:/usr/eslint-plugin - - /usr/eslint-plugin/tests - - ../../packages/types/:/usr/types - - /usr/types/tests - - ../../packages/visitor-keys/:/usr/visitor-keys - - /usr/visitor-keys/tests - - ../../packages/scope-manager/:/usr/scope-manager - - /usr/scope-manager/tests - - ../../packages/ast-spec/:/usr/ast-spec - - /usr/ast-spec/tests - # Runtime link to all the specific integration test files, so that most updates don't require a rebuild. - - ./fixtures/eslint-v6:/usr/linked diff --git a/tests/integration/fixtures/eslint-v6/.eslintrc.js b/tests/integration/fixtures/eslint-v6/.eslintrc.js index ad9ed9402981..9b8c1133a0ee 100644 --- a/tests/integration/fixtures/eslint-v6/.eslintrc.js +++ b/tests/integration/fixtures/eslint-v6/.eslintrc.js @@ -1,11 +1,7 @@ module.exports = { root: true, - // Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser', - plugins: [ - // Local version of @typescript-eslint/eslint-plugin - '@typescript-eslint', - ], + plugins: ['@typescript-eslint'], rules: { '@typescript-eslint/no-explicit-any': 'error', }, diff --git a/tests/integration/fixtures/eslint-v6/Dockerfile b/tests/integration/fixtures/eslint-v6/Dockerfile deleted file mode 100644 index 027ff085a6cf..000000000000 --- a/tests/integration/fixtures/eslint-v6/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:erbium - -# Copy the test.sh into the container. Every other file will be linked, rather -# than copied to allow for changes without rebuilds wherever possible -WORKDIR /usr -COPY ./test.sh /usr/ - -# Create file which will be executed by jest -# to assert that the lint output is what we expect -RUN echo "const actualLintOutput = require('./lint-output.json');\n" \ - "\n" \ - "test('it should produce the expected lint ouput', () => {\n" \ - " expect(actualLintOutput).toMatchSnapshot();\n" \ - "});\n" > test.js - -# Run the integration test -CMD [ "./test.sh" ] diff --git a/tests/integration/fixtures/eslint-v6/package.json b/tests/integration/fixtures/eslint-v6/package.json new file mode 100644 index 000000000000..71c2f5590c5f --- /dev/null +++ b/tests/integration/fixtures/eslint-v6/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "eslint": "6.0.0" + } +} diff --git a/tests/integration/fixtures/eslint-v6/test.sh b/tests/integration/fixtures/eslint-v6/test.sh deleted file mode 100755 index e2c988854164..000000000000 --- a/tests/integration/fixtures/eslint-v6/test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -# Generate the package.json to use -node /usr/utils/generate-package-json.js - -# Install dependencies -npm install -npm install eslint@6.0.0 - -# Use the local volumes for our own packages -npm install $(npm pack /usr/ast-spec | tail -1) -npm install $(npm pack /usr/types | tail -1) -npm install $(npm pack /usr/visitor-keys | tail -1) -npm install $(npm pack /usr/scope-manager | tail -1) -npm install $(npm pack /usr/typescript-estree | tail -1) -npm install $(npm pack /usr/parser | tail -1) -npm install $(npm pack /usr/experimental-utils | tail -1) -npm install $(npm pack /usr/eslint-plugin | tail -1) - -# Run the linting -# (the "|| true" helps make sure that we run our tests on failed linting runs as well) -npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.js /usr/linked/**/*.ts || true - -# Run our assertions against the linting output -npx jest /usr/test.js --snapshotResolver=/usr/utils/jest-snapshot-resolver.js diff --git a/tests/integration/fixtures/markdown/.eslintrc.js b/tests/integration/fixtures/markdown/.eslintrc.js index 53f147f80d85..9dd8a5505b98 100644 --- a/tests/integration/fixtures/markdown/.eslintrc.js +++ b/tests/integration/fixtures/markdown/.eslintrc.js @@ -1,6 +1,5 @@ module.exports = { root: true, - // Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser', env: { es6: true, @@ -13,13 +12,10 @@ module.exports = { jsx: true, }, }, - plugins: [ - 'markdown', - // Local version of @typescript-eslint/eslint-plugin - '@typescript-eslint', - ], + plugins: ['markdown', '@typescript-eslint'], overrides: [ { + // this will also ensure that eslint will force lint the markdown files files: ['**/*.md'], processor: 'markdown/markdown', }, diff --git a/tests/integration/fixtures/markdown/Dockerfile b/tests/integration/fixtures/markdown/Dockerfile deleted file mode 100644 index 027ff085a6cf..000000000000 --- a/tests/integration/fixtures/markdown/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:erbium - -# Copy the test.sh into the container. Every other file will be linked, rather -# than copied to allow for changes without rebuilds wherever possible -WORKDIR /usr -COPY ./test.sh /usr/ - -# Create file which will be executed by jest -# to assert that the lint output is what we expect -RUN echo "const actualLintOutput = require('./lint-output.json');\n" \ - "\n" \ - "test('it should produce the expected lint ouput', () => {\n" \ - " expect(actualLintOutput).toMatchSnapshot();\n" \ - "});\n" > test.js - -# Run the integration test -CMD [ "./test.sh" ] diff --git a/tests/integration/fixtures/markdown/package.json b/tests/integration/fixtures/markdown/package.json new file mode 100644 index 000000000000..a0cb6620d6cb --- /dev/null +++ b/tests/integration/fixtures/markdown/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "eslint-plugin-markdown": "latest" + } +} diff --git a/tests/integration/fixtures/markdown/test.sh b/tests/integration/fixtures/markdown/test.sh deleted file mode 100755 index 91e4c4f0a045..000000000000 --- a/tests/integration/fixtures/markdown/test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -# Generate the package.json to use -node /usr/utils/generate-package-json.js - -# Install dependencies -npm install - -# Use the local volumes for our own packages -npm install $(npm pack /usr/ast-spec | tail -1) -npm install $(npm pack /usr/types | tail -1) -npm install $(npm pack /usr/visitor-keys | tail -1) -npm install $(npm pack /usr/scope-manager | tail -1) -npm install $(npm pack /usr/typescript-estree | tail -1) -npm install $(npm pack /usr/parser | tail -1) -npm install $(npm pack /usr/experimental-utils | tail -1) -npm install $(npm pack /usr/eslint-plugin | tail -1) - -# Install the latest eslint-plugin-markdown (this may break us occassionally, but it's probably good to get that feedback early) -npm install eslint-plugin-markdown@latest - -# Run the linting -# (the "|| true" helps make sure that we run our tests on failed linting runs as well) -npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.js /usr/linked/**/*.md || true - -# Run our assertions against the linting output -npx jest /usr/test.js --snapshotResolver=/usr/utils/jest-snapshot-resolver.js diff --git a/tests/integration/fixtures/recommended-does-not-require-program/.eslintrc.js b/tests/integration/fixtures/recommended-does-not-require-program/.eslintrc.js index 85a83dc6e91e..0f28905d8de8 100644 --- a/tests/integration/fixtures/recommended-does-not-require-program/.eslintrc.js +++ b/tests/integration/fixtures/recommended-does-not-require-program/.eslintrc.js @@ -4,15 +4,11 @@ // more expensive checks. module.exports = { root: true, - // Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser', extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', ], - plugins: [ - // Local version of @typescript-eslint/eslint-plugin - '@typescript-eslint', - ], + plugins: ['@typescript-eslint'], }; diff --git a/tests/integration/fixtures/recommended-does-not-require-program/Dockerfile b/tests/integration/fixtures/recommended-does-not-require-program/Dockerfile deleted file mode 100644 index 027ff085a6cf..000000000000 --- a/tests/integration/fixtures/recommended-does-not-require-program/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:erbium - -# Copy the test.sh into the container. Every other file will be linked, rather -# than copied to allow for changes without rebuilds wherever possible -WORKDIR /usr -COPY ./test.sh /usr/ - -# Create file which will be executed by jest -# to assert that the lint output is what we expect -RUN echo "const actualLintOutput = require('./lint-output.json');\n" \ - "\n" \ - "test('it should produce the expected lint ouput', () => {\n" \ - " expect(actualLintOutput).toMatchSnapshot();\n" \ - "});\n" > test.js - -# Run the integration test -CMD [ "./test.sh" ] diff --git a/tests/integration/fixtures/recommended-does-not-require-program/package.json b/tests/integration/fixtures/recommended-does-not-require-program/package.json new file mode 100644 index 000000000000..6ae64c0520b4 --- /dev/null +++ b/tests/integration/fixtures/recommended-does-not-require-program/package.json @@ -0,0 +1,3 @@ +{ + "devDependencies": {} +} diff --git a/tests/integration/fixtures/recommended-does-not-require-program/test.sh b/tests/integration/fixtures/recommended-does-not-require-program/test.sh deleted file mode 100755 index ea25b6d7292d..000000000000 --- a/tests/integration/fixtures/recommended-does-not-require-program/test.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -# Generate the package.json to use -node /usr/utils/generate-package-json.js - -# Install dependencies -npm install - -# Use the local volumes for our own packages -npm install $(npm pack /usr/ast-spec | tail -1) -npm install $(npm pack /usr/types | tail -1) -npm install $(npm pack /usr/visitor-keys | tail -1) -npm install $(npm pack /usr/scope-manager | tail -1) -npm install $(npm pack /usr/typescript-estree | tail -1) -npm install $(npm pack /usr/parser | tail -1) -npm install $(npm pack /usr/experimental-utils | tail -1) -npm install $(npm pack /usr/eslint-plugin | tail -1) - -# Run the linting -# (the "|| true" helps make sure that we run our tests on failed linting runs as well) -npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.js /usr/linked/**/*.ts || true - -# Run our assertions against the linting output -npx jest /usr/test.js --snapshotResolver=/usr/utils/jest-snapshot-resolver.js diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.js b/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.js index 0409a42c42bb..c82da766e2c9 100644 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.js +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.js @@ -1,13 +1,7 @@ module.exports = { root: true, - // Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser', - plugins: [ - // Local version of @typescript-eslint/eslint-plugin - '@typescript-eslint', - // Local version of @typescript-eslint/eslint-plugin-tslint - '@typescript-eslint/tslint', - ], + plugins: ['@typescript-eslint', '@typescript-eslint/tslint'], env: { es6: true, node: true, diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/Dockerfile b/tests/integration/fixtures/typescript-and-tslint-plugins-together/Dockerfile deleted file mode 100644 index 027ff085a6cf..000000000000 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:erbium - -# Copy the test.sh into the container. Every other file will be linked, rather -# than copied to allow for changes without rebuilds wherever possible -WORKDIR /usr -COPY ./test.sh /usr/ - -# Create file which will be executed by jest -# to assert that the lint output is what we expect -RUN echo "const actualLintOutput = require('./lint-output.json');\n" \ - "\n" \ - "test('it should produce the expected lint ouput', () => {\n" \ - " expect(actualLintOutput).toMatchSnapshot();\n" \ - "});\n" > test.js - -# Run the integration test -CMD [ "./test.sh" ] diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/package.json b/tests/integration/fixtures/typescript-and-tslint-plugins-together/package.json new file mode 100644 index 000000000000..576b100099e2 --- /dev/null +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "tslint": "*" + } +} diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap deleted file mode 100644 index cc617dc19cc9..000000000000 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap +++ /dev/null @@ -1,49 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`it should produce the expected lint ouput 1`] = ` -Array [ - Object { - "errorCount": 1, - "fatalErrorCount": 0, - "filePath": "/usr/linked/index.ts", - "fixableErrorCount": 1, - "fixableWarningCount": 0, - "messages": Array [ - Object { - "column": 7, - "endColumn": 13, - "endLine": 2, - "line": 2, - "message": "'noSemi' is assigned a value but never used.", - "messageId": "unusedVar", - "nodeType": "Identifier", - "ruleId": "@typescript-eslint/no-unused-vars", - "severity": 1, - }, - Object { - "column": 20, - "endColumn": 20, - "endLine": 2, - "fix": Object { - "range": Array [ - 38, - 38, - ], - "text": ";", - }, - "line": 2, - "message": "Missing semicolon (tslint:semicolon)", - "messageId": "failure", - "nodeType": null, - "ruleId": "@typescript-eslint/tslint/config", - "severity": 2, - }, - ], - "source": "// prettier-ignore -const noSemi = true -", - "usedDeprecatedRules": Array [], - "warningCount": 1, - }, -] -`; diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh deleted file mode 100755 index 27c243e38081..000000000000 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -# Generate the package.json to use -node /usr/utils/generate-package-json.js - -# Install dependencies -npm install - -# Use the local volumes for our own packages -npm install $(npm pack /usr/ast-spec | tail -1) -npm install $(npm pack /usr/types | tail -1) -npm install $(npm pack /usr/visitor-keys | tail -1) -npm install $(npm pack /usr/scope-manager | tail -1) -npm install $(npm pack /usr/typescript-estree | tail -1) -npm install $(npm pack /usr/parser | tail -1) -npm install $(npm pack /usr/experimental-utils | tail -1) -npm install $(npm pack /usr/eslint-plugin-tslint | tail -1) -npm install $(npm pack /usr/eslint-plugin | tail -1) - -# Run the linting -# (the "|| true" helps make sure that we run our tests on failed linting runs as well) -npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.js /usr/linked/**/*.ts || true - -# Run our assertions against the linting output -npx jest /usr/test.js --snapshotResolver=/usr/utils/jest-snapshot-resolver.js diff --git a/tests/integration/fixtures/vue-jsx/.eslintrc.js b/tests/integration/fixtures/vue-jsx/.eslintrc.js index 0881ee92835d..750fe39d0bdc 100644 --- a/tests/integration/fixtures/vue-jsx/.eslintrc.js +++ b/tests/integration/fixtures/vue-jsx/.eslintrc.js @@ -7,7 +7,6 @@ module.exports = { }, extends: ['plugin:vue/essential'], parserOptions: { - // Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser', sourceType: 'module', extraFileExtensions: ['.vue'], @@ -15,10 +14,7 @@ module.exports = { jsx: true, }, }, - plugins: [ - // Local version of @typescript-eslint/eslint-plugin - '@typescript-eslint', - ], + plugins: ['@typescript-eslint'], rules: { '@typescript-eslint/no-explicit-any': 'error', }, diff --git a/tests/integration/fixtures/vue-jsx/Dockerfile b/tests/integration/fixtures/vue-jsx/Dockerfile deleted file mode 100644 index 027ff085a6cf..000000000000 --- a/tests/integration/fixtures/vue-jsx/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:erbium - -# Copy the test.sh into the container. Every other file will be linked, rather -# than copied to allow for changes without rebuilds wherever possible -WORKDIR /usr -COPY ./test.sh /usr/ - -# Create file which will be executed by jest -# to assert that the lint output is what we expect -RUN echo "const actualLintOutput = require('./lint-output.json');\n" \ - "\n" \ - "test('it should produce the expected lint ouput', () => {\n" \ - " expect(actualLintOutput).toMatchSnapshot();\n" \ - "});\n" > test.js - -# Run the integration test -CMD [ "./test.sh" ] diff --git a/tests/integration/fixtures/vue-jsx/package.json b/tests/integration/fixtures/vue-jsx/package.json new file mode 100644 index 000000000000..bef3a8935336 --- /dev/null +++ b/tests/integration/fixtures/vue-jsx/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "vue-eslint-parser": "latest", + "eslint-plugin-vue": "latest", + "vuex": "latest", + "vue-property-decorator": "latest" + } +} diff --git a/tests/integration/fixtures/vue-jsx/test.sh b/tests/integration/fixtures/vue-jsx/test.sh deleted file mode 100755 index fc41933a87ec..000000000000 --- a/tests/integration/fixtures/vue-jsx/test.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -# Generate the package.json to use -node /usr/utils/generate-package-json.js - -# Install dependencies -npm install - -# Use the local volumes for our own packages -npm install $(npm pack /usr/ast-spec | tail -1) -npm install $(npm pack /usr/types | tail -1) -npm install $(npm pack /usr/visitor-keys | tail -1) -npm install $(npm pack /usr/scope-manager | tail -1) -npm install $(npm pack /usr/typescript-estree | tail -1) -npm install $(npm pack /usr/parser | tail -1) -npm install $(npm pack /usr/experimental-utils | tail -1) -npm install $(npm pack /usr/eslint-plugin | tail -1) - -# Install the latest versions of dependencies (this may break us occassionally, but it's probably good to get that feedback early) -npm install vue-eslint-parser@latest eslint-plugin-vue@latest -# Install the latest some other vue utilities -npm install vuex@latest vue-property-decorator@latest - -# Run the linting -# (the "|| true" helps make sure that we run our tests on failed linting runs as well) -npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.js /usr/linked/**/*.vue || true - -# Run our assertions against the linting output -npx jest /usr/test.js --snapshotResolver=/usr/utils/jest-snapshot-resolver.js diff --git a/tests/integration/fixtures/vue-sfc/.eslintrc.js b/tests/integration/fixtures/vue-sfc/.eslintrc.js index 465684ec3ef2..3306fe237555 100644 --- a/tests/integration/fixtures/vue-sfc/.eslintrc.js +++ b/tests/integration/fixtures/vue-sfc/.eslintrc.js @@ -7,16 +7,12 @@ module.exports = { }, extends: ['plugin:vue/essential'], parserOptions: { - // Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser', project: '/usr/linked/tsconfig.json', sourceType: 'module', extraFileExtensions: ['.vue'], }, - plugins: [ - // Local version of @typescript-eslint/eslint-plugin - '@typescript-eslint', - ], + plugins: ['@typescript-eslint'], rules: { '@typescript-eslint/no-explicit-any': 'error', '@typescript-eslint/no-unnecessary-type-assertion': 'error', diff --git a/tests/integration/fixtures/vue-sfc/Dockerfile b/tests/integration/fixtures/vue-sfc/Dockerfile deleted file mode 100644 index 027ff085a6cf..000000000000 --- a/tests/integration/fixtures/vue-sfc/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM node:erbium - -# Copy the test.sh into the container. Every other file will be linked, rather -# than copied to allow for changes without rebuilds wherever possible -WORKDIR /usr -COPY ./test.sh /usr/ - -# Create file which will be executed by jest -# to assert that the lint output is what we expect -RUN echo "const actualLintOutput = require('./lint-output.json');\n" \ - "\n" \ - "test('it should produce the expected lint ouput', () => {\n" \ - " expect(actualLintOutput).toMatchSnapshot();\n" \ - "});\n" > test.js - -# Run the integration test -CMD [ "./test.sh" ] diff --git a/tests/integration/fixtures/vue-sfc/package.json b/tests/integration/fixtures/vue-sfc/package.json new file mode 100644 index 000000000000..bef3a8935336 --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/package.json @@ -0,0 +1,8 @@ +{ + "devDependencies": { + "vue-eslint-parser": "latest", + "eslint-plugin-vue": "latest", + "vuex": "latest", + "vue-property-decorator": "latest" + } +} diff --git a/tests/integration/fixtures/vue-sfc/test.sh b/tests/integration/fixtures/vue-sfc/test.sh deleted file mode 100755 index e22a51a62c62..000000000000 --- a/tests/integration/fixtures/vue-sfc/test.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -# Generate the package.json to use -node /usr/utils/generate-package-json.js - -# Install dependencies -npm install - -# Use the local volumes for our own packages -npm install $(npm pack /usr/ast-spec | tail -1) -npm install $(npm pack /usr/types | tail -1) -npm install $(npm pack /usr/visitor-keys | tail -1) -npm install $(npm pack /usr/scope-manager | tail -1) -npm install $(npm pack /usr/typescript-estree | tail -1) -npm install $(npm pack /usr/parser | tail -1) -npm install $(npm pack /usr/experimental-utils | tail -1) -npm install $(npm pack /usr/eslint-plugin | tail -1) - -# Install the latest versions of dependencies (this may break us occassionally, but it's probably good to get that feedback early) -npm install vue-eslint-parser@latest eslint-plugin-vue@latest -# Install the latest some other vue utilities -npm install vuex@latest vue-property-decorator@latest - -# Run the linting -# (the "|| true" helps make sure that we run our tests on failed linting runs as well) -npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.js /usr/linked/**/*.vue --fix-dry-run || true - -# Run our assertions against the linting output -npx jest /usr/test.js --snapshotResolver=/usr/utils/jest-snapshot-resolver.js diff --git a/tests/integration/integration-test-base.ts b/tests/integration/integration-test-base.ts new file mode 100644 index 000000000000..71c5934d9454 --- /dev/null +++ b/tests/integration/integration-test-base.ts @@ -0,0 +1,138 @@ +import childProcess from 'child_process'; +import fs from 'fs'; +import ncp from 'ncp'; +import path from 'path'; +import tmp from 'tmp'; +import { promisify } from 'util'; + +interface PackageJSON { + name: string; + private?: boolean; + devDependencies: Record; +} + +const rootPackageJson: PackageJSON = require('../../package.json'); + +tmp.setGracefulCleanup(); + +const copyDir = promisify(ncp.ncp); +const execFile = promisify(childProcess.execFile); +const readFile = promisify(fs.readFile); +const tmpDir = promisify(tmp.dir); +const tmpFile = promisify(tmp.file); +const writeFile = promisify(fs.writeFile); + +const BASE_DEPENDENCIES: PackageJSON['devDependencies'] = { + // @ts-expect-error -- this is in `./pack-packages.ts` + ...global.tseslintPackages, + eslint: rootPackageJson.devDependencies.eslint, + typescript: rootPackageJson.devDependencies.typescript, + jest: rootPackageJson.devDependencies.jest, +}; + +const FIXTURES_DIR = path.join(__dirname, 'fixtures'); + +// make sure that jest doesn't timeout the test +jest.setTimeout(60000); + +export function integrationTest(testFilename: string, filesGlob: string): void { + const fixture = path.parse(testFilename).name.replace('.test', ''); + describe(fixture, () => { + const fixtureDir = path.join(FIXTURES_DIR, fixture); + + it('should lint successfully', async () => { + const testFolder = await tmpDir(); + + // copy the fixture files to the temp folder + await copyDir(fixtureDir, testFolder); + + // build and write the package.json for the test + const fixturePackageJson: PackageJSON = await import( + path.join(fixtureDir, 'package.json') + ); + await writeFile( + path.join(testFolder, 'package.json'), + JSON.stringify({ + private: true, + devDependencies: { + ...BASE_DEPENDENCIES, + ...fixturePackageJson.devDependencies, + // install tslint with the base version if required + tslint: fixturePackageJson.devDependencies.tslint + ? rootPackageJson.devDependencies.tslint + : undefined, + }, + }), + ); + // console.log('package.json written.'); + + await new Promise((resolve, reject) => { + // we use the non-promise version so we can log everything on error + childProcess.execFile( + // we use yarn instead of npm as it will cache the remote packages and + // to make installs things faster + 'yarn', + ['install', '--no-lockfile', '--prefer-offline', '--no-progress'], + { + cwd: testFolder, + }, + (err, stdout, stderr) => { + if (err) { + if (stdout.length > 0) { + console.warn(stdout); + } + if (stderr.length > 0) { + console.error(stderr); + } + reject(err); + } else { + resolve(); + } + }, + ); + }); + // console.log('Install complete.'); + + // lint, outputting to a JSON file + const outFile = await tmpFile(); + try { + await execFile( + 'yarn', + [ + 'eslint', + '--format', + 'json', + '--output-file', + outFile, + '--config', + './.eslintrc.js', + '--fix-dry-run', + filesGlob, + ], + { + cwd: testFolder, + }, + ); + } catch (ex) { + // we expect eslint will "fail" because we have intentional lint errors + } + // console.log('Lint complete.'); + + // assert the linting state is consistent + const lintOutputRAW = (await readFile(outFile, 'utf8')) + // clean the output to remove any changing facets so tests are stable + .replace( + new RegExp(`"filePath": ?"(/private)?${testFolder}`, 'g'), + '"filePath": "', + ); + try { + const lintOutput = JSON.parse(lintOutputRAW); + expect(lintOutput).toMatchSnapshot(); + } catch { + throw lintOutputRAW; + } + }); + + afterAll(() => {}); + }); +} diff --git a/tests/integration/jest.config.js b/tests/integration/jest.config.js new file mode 100644 index 000000000000..cd6d67fdab01 --- /dev/null +++ b/tests/integration/jest.config.js @@ -0,0 +1,34 @@ +'use strict'; + +// pack the packages ahead of time and create a mapping for use in the tests +require('ts-node').register({ + transpileOnly: true, + files: ['./pack-packages.ts'], +}); +const { tseslintPackages } = require('./pack-packages'); + +module.exports = { + testEnvironment: 'node', + transform: { + ['^.+\\.tsx?$']: 'ts-jest', + }, + testRegex: ['/tests/[^/]+.test.ts$'], + collectCoverage: false, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], + globals: { + 'ts-jest': { + isolatedModules: true, + diagnostics: { + // ignore the diagnostic error for the invalidFileErrors fixtures + ignoreCodes: [5056], + }, + }, + tseslintPackages, + }, + rootDir: __dirname, + + // TODO(Brad Zacher) - for some reason if we run more than 1 test at a time + // yarn will error saying the tarballs are corrupt on just + // the first test. + maxWorkers: 1, +}; diff --git a/tests/integration/pack-packages.ts b/tests/integration/pack-packages.ts new file mode 100644 index 000000000000..6be072edb088 --- /dev/null +++ b/tests/integration/pack-packages.ts @@ -0,0 +1,52 @@ +/** + * Pack all of our packages so we can "install" them later. + * We do this here rather than per test so that we only have + * to do it once per test run as it takes a decent chunk of + * time to do. + * This also ensures all of the tests are guaranteed to run + * against the exact same version of the package. + */ + +import { spawnSync } from 'child_process'; +import fs from 'fs'; +import path from 'path'; +import tmp from 'tmp'; + +interface PackageJSON { + name: string; + private?: boolean; + devDependencies: Record; +} + +const PACKAGES_DIR = path.resolve(__dirname, '..', '..', 'packages'); +const PACKAGES = fs.readdirSync(PACKAGES_DIR); + +const tarFolder = tmp.dirSync({ + // because of how jest executes things, we need to ensure + // the temp files hang around + keep: true, +}).name; + +const tseslintPackages: PackageJSON['devDependencies'] = {}; +for (const pkg of PACKAGES) { + const packageDir = path.join(PACKAGES_DIR, pkg); + const packageJson: PackageJSON = require(path.join( + packageDir, + 'package.json', + )); + if (packageJson.private === true) { + continue; + } + + const result = spawnSync('npm', ['pack', packageDir], { + cwd: tarFolder, + encoding: 'utf-8', + }); + const stdoutLines = result.stdout.trim().split('\n'); + const tarball = stdoutLines[stdoutLines.length - 1]; + + tseslintPackages[packageJson.name] = `file:${path.join(tarFolder, tarball)}`; +} + +console.log('Finished packing local packages.'); +export { tseslintPackages }; diff --git a/tests/integration/run-all-tests.sh b/tests/integration/run-all-tests.sh deleted file mode 100755 index eccb4e2e157f..000000000000 --- a/tests/integration/run-all-tests.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -exuo pipefail - -# We run the services serially and in a non-detached state just that we can ensure predictable -# exit codes for all of our integration tests, and we can ensure CI builds pass or fail appropriately - -# typescript-and-tslint-plugins-together -docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-container-exit typescript-and-tslint-plugins-together - -# vue-sfc -docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-container-exit vue-sfc - -# vue-jsx -docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-container-exit vue-jsx - -# recommended-does-not-require-program -docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-container-exit recommended-does-not-require-program - -# markdown -docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-container-exit markdown - -# eslint-v6 -docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-container-exit eslint-v6 diff --git a/tests/integration/fixtures/eslint-v6/test.js.snap b/tests/integration/tests/__snapshots__/eslint-v6.test.ts.snap similarity index 85% rename from tests/integration/fixtures/eslint-v6/test.js.snap rename to tests/integration/tests/__snapshots__/eslint-v6.test.ts.snap index 350194ef759a..944108b5b194 100644 --- a/tests/integration/fixtures/eslint-v6/test.js.snap +++ b/tests/integration/tests/__snapshots__/eslint-v6.test.ts.snap @@ -1,10 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`it should produce the expected lint ouput 1`] = ` +exports[`eslint-v6 should lint successfully 1`] = ` Array [ Object { "errorCount": 1, - "filePath": "/usr/linked/index.ts", + "filePath": "/index.ts", "fixableErrorCount": 0, "fixableWarningCount": 0, "messages": Array [ diff --git a/tests/integration/fixtures/markdown/test.js.snap b/tests/integration/tests/__snapshots__/markdown.test.ts.snap similarity index 98% rename from tests/integration/fixtures/markdown/test.js.snap rename to tests/integration/tests/__snapshots__/markdown.test.ts.snap index 67725201aa8a..73ee869151ac 100644 --- a/tests/integration/fixtures/markdown/test.js.snap +++ b/tests/integration/tests/__snapshots__/markdown.test.ts.snap @@ -1,11 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`it should produce the expected lint ouput 1`] = ` +exports[`markdown should lint successfully 1`] = ` Array [ Object { "errorCount": 10, "fatalErrorCount": 0, - "filePath": "/usr/linked/Doc.md", + "filePath": "/Doc.md", "fixableErrorCount": 0, "fixableWarningCount": 0, "messages": Array [ diff --git a/tests/integration/fixtures/recommended-does-not-require-program/test.js.snap b/tests/integration/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap similarity index 65% rename from tests/integration/fixtures/recommended-does-not-require-program/test.js.snap rename to tests/integration/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap index 5b77306e5543..5bb7f69f1b82 100644 --- a/tests/integration/fixtures/recommended-does-not-require-program/test.js.snap +++ b/tests/integration/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap @@ -1,35 +1,17 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`it should produce the expected lint ouput 1`] = ` +exports[`recommended-does-not-require-program should lint successfully 1`] = ` Array [ Object { - "errorCount": 1, + "errorCount": 0, "fatalErrorCount": 0, - "filePath": "/usr/linked/index.ts", - "fixableErrorCount": 1, + "filePath": "/index.ts", + "fixableErrorCount": 0, "fixableWarningCount": 0, "messages": Array [ Object { - "column": 1, - "endColumn": 21, - "endLine": 1, - "fix": Object { - "range": Array [ - 0, - 3, - ], - "text": "let", - }, - "line": 1, - "message": "Unexpected var, use let or const instead.", - "messageId": "unexpectedVar", - "nodeType": "VariableDeclaration", - "ruleId": "no-var", - "severity": 2, - }, - Object { - "column": 5, - "endColumn": 13, + "column": 7, + "endColumn": 15, "endLine": 1, "line": 1, "message": "'foo' is assigned a value but never used.", @@ -39,8 +21,8 @@ Array [ "severity": 1, }, Object { - "column": 10, - "endColumn": 13, + "column": 12, + "endColumn": 15, "endLine": 1, "line": 1, "message": "Unexpected any. Specify a different type.", @@ -53,8 +35,8 @@ Array [ "desc": "Use \`unknown\` instead, this will force you to explicitly, and safely assert the type is correct.", "fix": Object { "range": Array [ - 9, - 12, + 11, + 14, ], "text": "unknown", }, @@ -64,8 +46,8 @@ Array [ "desc": "Use \`never\` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.", "fix": Object { "range": Array [ - 9, - 12, + 11, + 14, ], "text": "never", }, @@ -74,7 +56,7 @@ Array [ ], }, ], - "source": "var foo: any = true; + "output": "const foo: any = true; ", "usedDeprecatedRules": Array [], "warningCount": 2, diff --git a/tests/integration/tests/__snapshots__/typescript-and-tslint-plugins-together.test.ts.snap b/tests/integration/tests/__snapshots__/typescript-and-tslint-plugins-together.test.ts.snap new file mode 100644 index 000000000000..6febca576838 --- /dev/null +++ b/tests/integration/tests/__snapshots__/typescript-and-tslint-plugins-together.test.ts.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typescript-and-tslint-plugins-together should lint successfully 1`] = ` +Array [ + Object { + "errorCount": 1, + "fatalErrorCount": 1, + "filePath": "/index.ts", + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "messages": Array [ + Object { + "fatal": true, + "message": "Parsing error: Cannot read file '/usr/linked/tsconfig.json'.", + "ruleId": null, + "severity": 2, + }, + ], + "source": "// prettier-ignore +const noSemi = true +", + "usedDeprecatedRules": Array [], + "warningCount": 0, + }, +] +`; diff --git a/tests/integration/fixtures/vue-jsx/test.js.snap b/tests/integration/tests/__snapshots__/vue-jsx.test.ts.snap similarity index 96% rename from tests/integration/fixtures/vue-jsx/test.js.snap rename to tests/integration/tests/__snapshots__/vue-jsx.test.ts.snap index 6877b71a7e88..8801c5eff7cb 100644 --- a/tests/integration/fixtures/vue-jsx/test.js.snap +++ b/tests/integration/tests/__snapshots__/vue-jsx.test.ts.snap @@ -1,11 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`it should produce the expected lint ouput 1`] = ` +exports[`vue-jsx should lint successfully 1`] = ` Array [ Object { "errorCount": 1, "fatalErrorCount": 0, - "filePath": "/usr/linked/Jsx.vue", + "filePath": "/Jsx.vue", "fixableErrorCount": 0, "fixableWarningCount": 0, "messages": Array [ diff --git a/tests/integration/fixtures/vue-sfc/test.js.snap b/tests/integration/tests/__snapshots__/vue-sfc.test.ts.snap similarity index 51% rename from tests/integration/fixtures/vue-sfc/test.js.snap rename to tests/integration/tests/__snapshots__/vue-sfc.test.ts.snap index 3c0d7fc68a32..38c6ba890f8e 100644 --- a/tests/integration/fixtures/vue-sfc/test.js.snap +++ b/tests/integration/tests/__snapshots__/vue-sfc.test.ts.snap @@ -1,48 +1,19 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`it should produce the expected lint ouput 1`] = ` +exports[`vue-sfc should lint successfully 1`] = ` Array [ Object { "errorCount": 1, - "fatalErrorCount": 0, - "filePath": "/usr/linked/Hello.vue", + "fatalErrorCount": 1, + "filePath": "/Hello.vue", "fixableErrorCount": 0, "fixableWarningCount": 0, "messages": Array [ Object { - "column": 25, - "endColumn": 28, - "endLine": 33, - "line": 33, - "message": "Unexpected any. Specify a different type.", - "messageId": "unexpectedAny", - "nodeType": "TSAnyKeyword", - "ruleId": "@typescript-eslint/no-explicit-any", + "fatal": true, + "message": "Parsing error: Cannot read file '/usr/linked/tsconfig.json'.", + "ruleId": null, "severity": 2, - "suggestions": Array [ - Object { - "desc": "Use \`unknown\` instead, this will force you to explicitly, and safely assert the type is correct.", - "fix": Object { - "range": Array [ - 648, - 651, - ], - "text": "unknown", - }, - "messageId": "suggestUnknown", - }, - Object { - "desc": "Use \`never\` instead, this is useful when instantiating generic type parameters that you don't need to know the type of.", - "fix": Object { - "range": Array [ - 648, - 651, - ], - "text": "never", - }, - "messageId": "suggestNever", - }, - ], }, ], "source": " @@ -89,13 +60,20 @@ export default Vue.extend({ "warningCount": 0, }, Object { - "errorCount": 0, - "fatalErrorCount": 0, - "filePath": "/usr/linked/Utility.vue", + "errorCount": 1, + "fatalErrorCount": 1, + "filePath": "/Utility.vue", "fixableErrorCount": 0, "fixableWarningCount": 0, - "messages": Array [], - "output": " +", "usedDeprecatedRules": Array [], "warningCount": 0, }, diff --git a/tests/integration/tests/eslint-v6.test.ts b/tests/integration/tests/eslint-v6.test.ts new file mode 100644 index 000000000000..afcf9da3bc25 --- /dev/null +++ b/tests/integration/tests/eslint-v6.test.ts @@ -0,0 +1,3 @@ +import { integrationTest } from '../integration-test-base'; + +integrationTest(__filename, '*.ts'); diff --git a/tests/integration/tests/markdown.test.ts b/tests/integration/tests/markdown.test.ts new file mode 100644 index 000000000000..8ac7befb646b --- /dev/null +++ b/tests/integration/tests/markdown.test.ts @@ -0,0 +1,3 @@ +import { integrationTest } from '../integration-test-base'; + +integrationTest(__filename, '*.md'); diff --git a/tests/integration/tests/recommended-does-not-require-program.test.ts b/tests/integration/tests/recommended-does-not-require-program.test.ts new file mode 100644 index 000000000000..afcf9da3bc25 --- /dev/null +++ b/tests/integration/tests/recommended-does-not-require-program.test.ts @@ -0,0 +1,3 @@ +import { integrationTest } from '../integration-test-base'; + +integrationTest(__filename, '*.ts'); diff --git a/tests/integration/tests/typescript-and-tslint-plugins-together.test.ts b/tests/integration/tests/typescript-and-tslint-plugins-together.test.ts new file mode 100644 index 000000000000..afcf9da3bc25 --- /dev/null +++ b/tests/integration/tests/typescript-and-tslint-plugins-together.test.ts @@ -0,0 +1,3 @@ +import { integrationTest } from '../integration-test-base'; + +integrationTest(__filename, '*.ts'); diff --git a/tests/integration/tests/vue-jsx.test.ts b/tests/integration/tests/vue-jsx.test.ts new file mode 100644 index 000000000000..18a482247acf --- /dev/null +++ b/tests/integration/tests/vue-jsx.test.ts @@ -0,0 +1,3 @@ +import { integrationTest } from '../integration-test-base'; + +integrationTest(__filename, '*.vue'); diff --git a/tests/integration/tests/vue-sfc.test.ts b/tests/integration/tests/vue-sfc.test.ts new file mode 100644 index 000000000000..18a482247acf --- /dev/null +++ b/tests/integration/tests/vue-sfc.test.ts @@ -0,0 +1,3 @@ +import { integrationTest } from '../integration-test-base'; + +integrationTest(__filename, '*.vue'); diff --git a/tests/integration/tsconfig.json b/tests/integration/tsconfig.json new file mode 100644 index 000000000000..e6c02e537a66 --- /dev/null +++ b/tests/integration/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "esModuleInterop": true, + "resolveJsonModule": true, + "rootDir": "." + }, + "include": ["./*.ts", "./tests/*.test.ts"], + "references": [] +} diff --git a/tests/integration/utils/.eslintrc.js b/tests/integration/utils/.eslintrc.js deleted file mode 100644 index 8ca32766a124..000000000000 --- a/tests/integration/utils/.eslintrc.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - parserOptions: { - project: `${__dirname}/jsconfig.json`, - }, -}; diff --git a/tests/integration/utils/generate-package-json.js b/tests/integration/utils/generate-package-json.js deleted file mode 100644 index d627cc889b8a..000000000000 --- a/tests/integration/utils/generate-package-json.js +++ /dev/null @@ -1,21 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ - -const fs = require('fs'); -// eslint-disable-next-line import/no-absolute-path -const rootPackageJSON = require('/usr/root-package.json'); - -/** - * Apply package versions based on what they are currently set to in the root package.json - * in the monorepo. - */ -const testPackageJSON = { - private: true, - devDependencies: { - eslint: rootPackageJSON.devDependencies.eslint, - typescript: rootPackageJSON.devDependencies.typescript, - tslint: rootPackageJSON.devDependencies.tslint, - jest: rootPackageJSON.devDependencies.jest, - }, -}; - -fs.writeFileSync('/usr/package.json', JSON.stringify(testPackageJSON, null, 2)); diff --git a/tests/integration/utils/jest-snapshot-resolver.js b/tests/integration/utils/jest-snapshot-resolver.js deleted file mode 100644 index 3032ef5d575c..000000000000 --- a/tests/integration/utils/jest-snapshot-resolver.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Use a jest snapshotResolver to map the test snapshot output back to the - * linked volume. This means that even though we are running our tests inside - * the docker container, the resulting snapshots will get written back to disk - * on the host machine (i.e. your computer)! ✨ - */ -module.exports = { - // resolves from test to snapshot path - resolveSnapshotPath: (testPath, snapshotExtension) => { - return testPath.replace('/usr/', '/usr/linked/') + snapshotExtension; - }, - // resolves from snapshot to test path - resolveTestPath: (snapshotFilePath, snapshotExtension) => { - return snapshotFilePath - .replace('/usr/linked/', '/usr/') - .slice(0, -snapshotExtension.length); - }, - testPathForConsistencyCheck: '/usr/test.js', -}; diff --git a/tests/integration/utils/jsconfig.json b/tests/integration/utils/jsconfig.json deleted file mode 100644 index 984f1f4c0780..000000000000 --- a/tests/integration/utils/jsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "include": [ - ".eslintrc.js", - "jest-snapshot-resolver.js", - "generate-package-json.js" - ] -} diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 16ced4c0241c..102bb2a44e3d 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -5,10 +5,5 @@ "allowJs": true }, "extends": "./tsconfig.base.json", - "include": [ - "tests/**/*.ts", - "tools/**/*.ts", - ".eslintrc.js", - "tests/jest-resolver.js" - ] + "include": ["tools/**/*.ts", ".eslintrc.js", "tests/jest-resolver.js"] } diff --git a/yarn.lock b/yarn.lock index 5486c7f7140c..9b76320d02b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2271,6 +2271,13 @@ resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.31.tgz#31b7ca6407128a3d2bbc27fe2d21b345397f6197" integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== +"@types/ncp@^2.0.5": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@types/ncp/-/ncp-2.0.5.tgz#5c53b229a321946102a188b603306162137f4fb9" + integrity sha512-ocK0p8JuFmX7UkMabFPjY0F7apPvQyLWt5qtdvuvQEBz9i4m2dbzV+6L1zNaUp042RfnL6pHnxDE53OH6XQ9VQ== + dependencies: + "@types/node" "*" + "@types/node@*", "@types/node@12.20.24", "@types/node@>= 8", "@types/node@^16.11.4": version "16.11.4" resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.4.tgz#90771124822d6663814f7c1c9b45a6654d8fd964" @@ -7355,6 +7362,11 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= +ncp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ncp/-/ncp-2.0.0.tgz#195a21d6c46e361d2fb1281ba38b91e9df7bdbb3" + integrity sha1-GVoh1sRuNh0vsSgbo4uR6d9727M= + neo-async@^2.6.0: version "2.6.2" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" @@ -9419,6 +9431,13 @@ timsort@~0.3.0: resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= +tmp@*, tmp@^0.2.1, tmp@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" + integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== + dependencies: + rimraf "^3.0.0" + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -9426,13 +9445,6 @@ tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" -tmp@^0.2.1, tmp@~0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" - integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== - dependencies: - rimraf "^3.0.0" - tmpl@1.0.x: version "1.0.5" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.5.tgz#8683e0b902bb9c20c4f726e3c0b69f36518c07cc" From 475caa46c64a74b169680b2f82925ca8b99ab498 Mon Sep 17 00:00:00 2001 From: Kyle Peeler Date: Sun, 31 Oct 2021 20:18:04 -0700 Subject: [PATCH 05/10] docs(eslint-plugin): Fix `consistent-type-definitions` README with correct usage of type (#4039) --- .../eslint-plugin/docs/rules/consistent-type-definitions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md index f58a138ec8cd..6f91d480e52d 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-definitions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-definitions.md @@ -59,7 +59,7 @@ interface T { } ``` -Examples of **correct** code with `interface` option. +Examples of **correct** code with `type` option. ```ts type T = { x: number }; From 5229597d9bfc998852c4b4fb421859e8f3d3d688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 1 Nov 2021 04:27:20 +0100 Subject: [PATCH 06/10] feat(experimental-utils): extract `isTokenOfTypeWithConditions` out of `ast-utils`' `predicates` (#3977) --- .../src/ast-utils/helpers.ts | 27 +++++++++++++++-- .../src/ast-utils/predicates.ts | 29 +++++++++---------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/packages/experimental-utils/src/ast-utils/helpers.ts b/packages/experimental-utils/src/ast-utils/helpers.ts index 5d917df603a1..f2a4ac2e2442 100644 --- a/packages/experimental-utils/src/ast-utils/helpers.ts +++ b/packages/experimental-utils/src/ast-utils/helpers.ts @@ -1,4 +1,7 @@ -import { AST_NODE_TYPES, TSESTree } from '../ts-estree'; +import { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree } from '../ts-estree'; + +type ObjectEntry = [keyof BaseType, BaseType[keyof BaseType]]; +type ObjectEntries = Array>; export const isNodeOfType = (nodeType: NodeType) => @@ -14,8 +17,6 @@ export const isNodeOfTypes = ): node is TSESTree.Node & { type: NodeTypes[number] } => !!node && nodeTypes.includes(node.type); -type ObjectEntry = [keyof BaseType, BaseType[keyof BaseType]]; -type ObjectEntries = Array>; export const isNodeOfTypeWithConditions = < NodeType extends AST_NODE_TYPES, Conditions extends Partial, @@ -35,3 +36,23 @@ export const isNodeOfTypeWithConditions = < node?.type === nodeType && entries.every(([key, value]) => node[key] === value); }; + +export const isTokenOfTypeWithConditions = < + TokenType extends AST_TOKEN_TYPES, + Conditions extends Partial, +>( + tokenType: TokenType, + conditions: Conditions, +): (( + token: TSESTree.Token | null | undefined, +) => token is TSESTree.Token & { type: TokenType } & Conditions) => { + const entries = Object.entries(conditions) as ObjectEntries< + TSESTree.Token & { type: TokenType } + >; + + return ( + token: TSESTree.Token | null | undefined, + ): token is TSESTree.Token & { type: TokenType } & Conditions => + token?.type === tokenType && + entries.every(([key, value]) => token[key] === value); +}; diff --git a/packages/experimental-utils/src/ast-utils/predicates.ts b/packages/experimental-utils/src/ast-utils/predicates.ts index 985c6e976238..0038f092bbe0 100644 --- a/packages/experimental-utils/src/ast-utils/predicates.ts +++ b/packages/experimental-utils/src/ast-utils/predicates.ts @@ -4,13 +4,14 @@ import { isNodeOfType, isNodeOfTypes, isNodeOfTypeWithConditions, + isTokenOfTypeWithConditions, } from './helpers'; -function isOptionalChainPunctuator( - token: TSESTree.Token, -): token is TSESTree.PunctuatorToken & { value: '?.' } { - return token.type === AST_TOKEN_TYPES.Punctuator && token.value === '?.'; -} +const isOptionalChainPunctuator = isTokenOfTypeWithConditions( + AST_TOKEN_TYPES.Punctuator, + { value: '?.' }, +); + function isNotOptionalChainPunctuator( token: TSESTree.Token, ): token is Exclude< @@ -20,11 +21,11 @@ function isNotOptionalChainPunctuator( return !isOptionalChainPunctuator(token); } -function isNonNullAssertionPunctuator( - token: TSESTree.Token, -): token is TSESTree.PunctuatorToken & { value: '!' } { - return token.type === AST_TOKEN_TYPES.Punctuator && token.value === '!'; -} +const isNonNullAssertionPunctuator = isTokenOfTypeWithConditions( + AST_TOKEN_TYPES.Punctuator, + { value: '!' }, +); + function isNotNonNullAssertionPunctuator( token: TSESTree.Token, ): token is Exclude { @@ -138,11 +139,9 @@ const isAwaitExpression = isNodeOfType(AST_NODE_TYPES.AwaitExpression); /** * Checks if a possible token is the `await` keyword. */ -function isAwaitKeyword( - node: TSESTree.Token | undefined | null, -): node is TSESTree.IdentifierToken & { value: 'await' } { - return node?.type === AST_TOKEN_TYPES.Identifier && node.value === 'await'; -} +const isAwaitKeyword = isTokenOfTypeWithConditions(AST_TOKEN_TYPES.Identifier, { + value: 'await', +}); const isLoop = isNodeOfTypes([ AST_NODE_TYPES.DoWhileStatement, From a93cebfc0f2026c50972bcb110bcd3295ba9a44d Mon Sep 17 00:00:00 2001 From: Idan Attias Date: Mon, 1 Nov 2021 05:29:14 +0200 Subject: [PATCH 07/10] feat(eslint-plugin): [no-shadow] exclude external type declaration merging (#3959) * fix(eslint-plugin): [no-shadow] exclude external type declaration merging * fix(eslint-plugin): [no-shadow] typo * Apply suggestions from code review Co-authored-by: Josh Goldberg * fix(eslint-plugin): lint - remove isStringLiteral (no longer used) Co-authored-by: Josh Goldberg --- packages/eslint-plugin/src/rules/no-shadow.ts | 49 ++++++++++- .../tests/rules/no-shadow.test.ts | 87 +++++++++++++++++++ 2 files changed, 134 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-shadow.ts b/packages/eslint-plugin/src/rules/no-shadow.ts index 27c689309310..dfba42cf301e 100644 --- a/packages/eslint-plugin/src/rules/no-shadow.ts +++ b/packages/eslint-plugin/src/rules/no-shadow.ts @@ -94,10 +94,10 @@ export default util.createRule({ } function isTypeImport( - definition: Definition, + definition?: Definition, ): definition is ImportBindingDefinition { return ( - definition.type === DefinitionType.ImportBinding && + definition?.type === DefinitionType.ImportBinding && definition.parent.importKind === 'type' ); } @@ -224,6 +224,47 @@ export default util.createRule({ ); } + function isImportDeclaration( + definition: + | TSESTree.ImportDeclaration + | TSESTree.TSImportEqualsDeclaration, + ): definition is TSESTree.ImportDeclaration { + return definition.type === AST_NODE_TYPES.ImportDeclaration; + } + + function isExternalModuleDeclarationWithName( + scope: TSESLint.Scope.Scope, + name: string, + ): boolean { + return ( + scope.type === ScopeType.tsModule && + scope.block.type === AST_NODE_TYPES.TSModuleDeclaration && + scope.block.id.type === AST_NODE_TYPES.Literal && + scope.block.id.value === name + ); + } + + function isExternalDeclarationMerging( + scope: TSESLint.Scope.Scope, + variable: TSESLint.Scope.Variable, + shadowed: TSESLint.Scope.Variable, + ): boolean { + const [firstDefinition] = shadowed.defs; + const [secondDefinition] = variable.defs; + + return ( + isTypeImport(firstDefinition) && + isImportDeclaration(firstDefinition.parent) && + isExternalModuleDeclarationWithName( + scope, + firstDefinition.parent.source.value, + ) && + secondDefinition.node.type === AST_NODE_TYPES.TSInterfaceDeclaration && + secondDefinition.node.parent?.type === + AST_NODE_TYPES.ExportNamedDeclaration + ); + } + /** * Check if variable name is allowed. * @param variable The variable to check. @@ -403,6 +444,10 @@ export default util.createRule({ continue; } + if (isExternalDeclarationMerging(scope, variable, shadowed)) { + continue; + } + const isESLintGlobal = 'writeable' in shadowed; if ( (shadowed.identifiers.length > 0 || diff --git a/packages/eslint-plugin/tests/rules/no-shadow.test.ts b/packages/eslint-plugin/tests/rules/no-shadow.test.ts index c3e5a09f3441..bedb825df704 100644 --- a/packages/eslint-plugin/tests/rules/no-shadow.test.ts +++ b/packages/eslint-plugin/tests/rules/no-shadow.test.ts @@ -51,6 +51,15 @@ class Foo { } interface Foo { prop2: string; +} + `, + ` +import type { Foo } from 'bar'; + +declare module 'bar' { + export interface Foo { + x: string; + } } `, // type value shadowing @@ -1442,5 +1451,83 @@ function doThing(foo: number, bar: number) {} }, ], }, + { + code: ` +interface Foo {} + +declare module 'bar' { + export interface Foo { + x: string; + } +} + `, + errors: [ + { + messageId: 'noShadow', + data: { name: 'Foo' }, + type: AST_NODE_TYPES.Identifier, + line: 5, + column: 20, + }, + ], + }, + { + code: ` +import type { Foo } from 'bar'; + +declare module 'baz' { + export interface Foo { + x: string; + } +} + `, + errors: [ + { + messageId: 'noShadow', + data: { name: 'Foo' }, + type: AST_NODE_TYPES.Identifier, + line: 5, + column: 20, + }, + ], + }, + { + code: ` +import type { Foo } from 'bar'; + +declare module 'bar' { + export type Foo = string; +} + `, + errors: [ + { + messageId: 'noShadow', + data: { name: 'Foo' }, + type: AST_NODE_TYPES.Identifier, + line: 5, + column: 15, + }, + ], + }, + { + code: ` +import type { Foo } from 'bar'; + +declare module 'bar' { + interface Foo { + x: string; + } +} + `, + errors: [ + { + messageId: 'noShadow', + data: { name: 'Foo' }, + type: AST_NODE_TYPES.Identifier, + line: 5, + column: 13, + }, + ], + }, ], }); From 80b853db90ae3d4e32c4b7ec9d45a5c41dc459c9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 31 Oct 2021 23:30:18 -0400 Subject: [PATCH 08/10] fix(eslint-plugin): ignore private identifiers in explicit-module-boundary-types (#4046) --- .../src/rules/explicit-module-boundary-types.ts | 10 ++++++++-- .../tests/rules/explicit-module-boundary-types.test.ts | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index e189727463f3..adaacaf363f6 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -336,7 +336,10 @@ export default util.createRule({ return; case AST_NODE_TYPES.PropertyDefinition: - if (node.accessibility === 'private') { + if ( + node.accessibility === 'private' || + node.key.type === AST_NODE_TYPES.PrivateIdentifier + ) { return; } return checkNode(node.value); @@ -353,7 +356,10 @@ export default util.createRule({ case AST_NODE_TYPES.MethodDefinition: case AST_NODE_TYPES.TSAbstractMethodDefinition: - if (node.accessibility === 'private') { + if ( + node.accessibility === 'private' || + node.key.type === AST_NODE_TYPES.PrivateIdentifier + ) { return; } return checkNode(node.value); diff --git a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts index ba80da5b588d..e511e29d682b 100644 --- a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts @@ -82,6 +82,16 @@ export class Test { } `, }, + ` +export class PrivateProperty { + #property = () => null; +} + `, + ` +export class PrivateMethod { + #method() {} +} + `, { // https://github.com/typescript-eslint/typescript-eslint/issues/2150 code: ` From 6af7ca7d9fde230342d27ad5a75a09a58c022974 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 1 Nov 2021 00:59:29 -0400 Subject: [PATCH 09/10] fix(eslint-plugin): skip seenTypes for unions in isTypeReadonly (#4043) --- packages/eslint-plugin/src/util/isTypeReadonly.ts | 6 ++++-- .../rules/prefer-readonly-parameter-types.test.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin/src/util/isTypeReadonly.ts b/packages/eslint-plugin/src/util/isTypeReadonly.ts index 8b3efc27856e..8231455c294f 100644 --- a/packages/eslint-plugin/src/util/isTypeReadonly.ts +++ b/packages/eslint-plugin/src/util/isTypeReadonly.ts @@ -185,8 +185,10 @@ function isTypeReadonlyRecurser( if (isUnionType(type)) { // all types in the union must be readonly - const result = unionTypeParts(type).every(t => - isTypeReadonlyRecurser(checker, t, options, seenTypes), + const result = unionTypeParts(type).every( + t => + seenTypes.has(t) || + isTypeReadonlyRecurser(checker, t, options, seenTypes), ); const readonlyness = result ? Readonlyness.Readonly : Readonlyness.Mutable; return readonlyness; diff --git a/packages/eslint-plugin/tests/rules/prefer-readonly-parameter-types.test.ts b/packages/eslint-plugin/tests/rules/prefer-readonly-parameter-types.test.ts index 0a6ee1038073..be50f096963a 100644 --- a/packages/eslint-plugin/tests/rules/prefer-readonly-parameter-types.test.ts +++ b/packages/eslint-plugin/tests/rules/prefer-readonly-parameter-types.test.ts @@ -280,13 +280,23 @@ ruleTester.run('prefer-readonly-parameter-types', rule, { `, // TSMethodSignature // https://github.com/typescript-eslint/typescript-eslint/issues/1665 - // directly recursive + // directly recursive interface ` interface Foo { readonly prop: Foo; } function foo(arg: Foo) {} `, + + // https://github.com/typescript-eslint/typescript-eslint/issues/3396 + // directly recursive union type + ` + type MyType = string | readonly MyType[]; + + function foo(a: A): MyType[] { + return []; + } + `, // indirectly recursive ` interface Foo { From c289d1358c62c41847ee2f32d135f13321dca177 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 1 Nov 2021 17:01:59 +0000 Subject: [PATCH 10/10] chore: publish v5.3.0 --- CHANGELOG.md | 19 +++++++++++++++++++ lerna.json | 2 +- packages/ast-spec/CHANGELOG.md | 8 ++++++++ packages/ast-spec/package.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-internal/package.json | 6 +++--- packages/eslint-plugin-tslint/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 17 +++++++++++++++++ packages/eslint-plugin/package.json | 6 +++--- packages/experimental-utils/CHANGELOG.md | 16 ++++++++++++++++ packages/experimental-utils/package.json | 8 ++++---- packages/parser/CHANGELOG.md | 8 ++++++++ packages/parser/package.json | 10 +++++----- packages/scope-manager/CHANGELOG.md | 8 ++++++++ packages/scope-manager/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/types/CHANGELOG.md | 8 ++++++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 8 ++++++++ packages/typescript-estree/package.json | 8 ++++---- packages/visitor-keys/CHANGELOG.md | 8 ++++++++ packages/visitor-keys/package.json | 4 ++-- 24 files changed, 156 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c5cc0312b2..b1186a12eb8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,25 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + + +### Bug Fixes + +* **eslint-plugin:** ignore private identifiers in explicit-module-boundary-types ([#4046](https://github.com/typescript-eslint/typescript-eslint/issues/4046)) ([80b853d](https://github.com/typescript-eslint/typescript-eslint/commit/80b853db90ae3d4e32c4b7ec9d45a5c41dc459c9)) +* **eslint-plugin:** skip seenTypes for unions in isTypeReadonly ([#4043](https://github.com/typescript-eslint/typescript-eslint/issues/4043)) ([6af7ca7](https://github.com/typescript-eslint/typescript-eslint/commit/6af7ca7d9fde230342d27ad5a75a09a58c022974)) +* **experimental-utils:** add `name` property to test case interface ([#4067](https://github.com/typescript-eslint/typescript-eslint/issues/4067)) ([f3021c9](https://github.com/typescript-eslint/typescript-eslint/commit/f3021c94460e8d06e4169335bcc1a23854531f2a)) + + +### Features + +* **eslint-plugin:** [no-shadow] exclude external type declaration merging ([#3959](https://github.com/typescript-eslint/typescript-eslint/issues/3959)) ([a93cebf](https://github.com/typescript-eslint/typescript-eslint/commit/a93cebfc0f2026c50972bcb110bcd3295ba9a44d)) +* **experimental-utils:** extract `isTokenOfTypeWithConditions` out of `ast-utils`' `predicates` ([#3977](https://github.com/typescript-eslint/typescript-eslint/issues/3977)) ([5229597](https://github.com/typescript-eslint/typescript-eslint/commit/5229597d9bfc998852c4b4fb421859e8f3d3d688)) + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) diff --git a/lerna.json b/lerna.json index 5a7c00795bc8..0247b06e8869 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "5.2.0", + "version": "5.3.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/ast-spec/CHANGELOG.md b/packages/ast-spec/CHANGELOG.md index b86a98cc4fee..9a0a4f4869a6 100644 --- a/packages/ast-spec/CHANGELOG.md +++ b/packages/ast-spec/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/ast-spec + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/ast-spec diff --git a/packages/ast-spec/package.json b/packages/ast-spec/package.json index dad8afb2e9d7..905a4eec05e5 100644 --- a/packages/ast-spec/package.json +++ b/packages/ast-spec/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/ast-spec", - "version": "5.2.0", + "version": "5.3.0", "description": "TypeScript-ESTree AST spec", "private": true, "keywords": [ diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index e9951fed79d4..63eec6987363 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index 5382fe8b7f5c..5ee193ea771d 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-internal", - "version": "5.2.0", + "version": "5.3.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,8 +14,8 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/experimental-utils": "5.2.0", - "@typescript-eslint/scope-manager": "5.2.0", + "@typescript-eslint/experimental-utils": "5.3.0", + "@typescript-eslint/scope-manager": "5.3.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index dff4a4ca5ec8..71737e6edff4 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 884eec72cd90..1a178b917f6e 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "5.2.0", + "version": "5.3.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "5.2.0", + "@typescript-eslint/experimental-utils": "5.3.0", "lodash": "^4.17.21" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "5.2.0" + "@typescript-eslint/parser": "5.3.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 897e4a7bd873..d102d6349394 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + + +### Bug Fixes + +* **eslint-plugin:** ignore private identifiers in explicit-module-boundary-types ([#4046](https://github.com/typescript-eslint/typescript-eslint/issues/4046)) ([80b853d](https://github.com/typescript-eslint/typescript-eslint/commit/80b853db90ae3d4e32c4b7ec9d45a5c41dc459c9)) +* **eslint-plugin:** skip seenTypes for unions in isTypeReadonly ([#4043](https://github.com/typescript-eslint/typescript-eslint/issues/4043)) ([6af7ca7](https://github.com/typescript-eslint/typescript-eslint/commit/6af7ca7d9fde230342d27ad5a75a09a58c022974)) + + +### Features + +* **eslint-plugin:** [no-shadow] exclude external type declaration merging ([#3959](https://github.com/typescript-eslint/typescript-eslint/issues/3959)) ([a93cebf](https://github.com/typescript-eslint/typescript-eslint/commit/a93cebfc0f2026c50972bcb110bcd3295ba9a44d)) + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 6598833357e9..9655d60e8062 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "5.2.0", + "version": "5.3.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -44,8 +44,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "5.2.0", - "@typescript-eslint/scope-manager": "5.2.0", + "@typescript-eslint/experimental-utils": "5.3.0", + "@typescript-eslint/scope-manager": "5.3.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 5ac17483fbd8..a34dfcce822b 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + + +### Bug Fixes + +* **experimental-utils:** add `name` property to test case interface ([#4067](https://github.com/typescript-eslint/typescript-eslint/issues/4067)) ([f3021c9](https://github.com/typescript-eslint/typescript-eslint/commit/f3021c94460e8d06e4169335bcc1a23854531f2a)) + + +### Features + +* **experimental-utils:** extract `isTokenOfTypeWithConditions` out of `ast-utils`' `predicates` ([#3977](https://github.com/typescript-eslint/typescript-eslint/issues/3977)) ([5229597](https://github.com/typescript-eslint/typescript-eslint/commit/5229597d9bfc998852c4b4fb421859e8f3d3d688)) + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/experimental-utils diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index d541df285e6f..32fdeffd18ff 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "5.2.0", + "version": "5.3.0", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -40,9 +40,9 @@ }, "dependencies": { "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.2.0", - "@typescript-eslint/types": "5.2.0", - "@typescript-eslint/typescript-estree": "5.2.0", + "@typescript-eslint/scope-manager": "5.3.0", + "@typescript-eslint/types": "5.3.0", + "@typescript-eslint/typescript-estree": "5.3.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" }, diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index 2306061ddabd..76239c9ee34c 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/parser + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 9e4a35b7674b..9021564e2cf8 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "5.2.0", + "version": "5.3.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -44,14 +44,14 @@ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "dependencies": { - "@typescript-eslint/scope-manager": "5.2.0", - "@typescript-eslint/types": "5.2.0", - "@typescript-eslint/typescript-estree": "5.2.0", + "@typescript-eslint/scope-manager": "5.3.0", + "@typescript-eslint/types": "5.3.0", + "@typescript-eslint/typescript-estree": "5.3.0", "debug": "^4.3.2" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/experimental-utils": "5.2.0", + "@typescript-eslint/experimental-utils": "5.3.0", "glob": "*", "typescript": "*" }, diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index d33343eea666..e3890cbc7932 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/scope-manager + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/scope-manager diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index 5c165d5f6590..0c49d224fe15 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "5.2.0", + "version": "5.3.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -39,12 +39,12 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.2.0", - "@typescript-eslint/visitor-keys": "5.2.0" + "@typescript-eslint/types": "5.3.0", + "@typescript-eslint/visitor-keys": "5.3.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "5.2.0", + "@typescript-eslint/typescript-estree": "5.3.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index a0a14ca11d2d..5710ecc6d806 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index f4e6b228d3a7..84b82a7c58ab 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "5.2.0", + "version": "5.3.0", "private": true } diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index e8ef5f9fda77..4054d4a4f693 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/types + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index bf14776d5c7a..4ab50f039d36 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "5.2.0", + "version": "5.3.0", "description": "Types for the TypeScript-ESTree AST spec", "keywords": [ "eslint", diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 43fe405d7f19..d33e8663db7b 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/typescript-estree diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index a5717e134417..c77bd556e096 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "5.2.0", + "version": "5.3.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,8 +41,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.2.0", - "@typescript-eslint/visitor-keys": "5.2.0", + "@typescript-eslint/types": "5.3.0", + "@typescript-eslint/visitor-keys": "5.3.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -59,7 +59,7 @@ "@types/is-glob": "*", "@types/semver": "*", "@types/tmp": "*", - "@typescript-eslint/shared-fixtures": "5.2.0", + "@typescript-eslint/shared-fixtures": "5.3.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index 41356867cefb..27a7b5a9b4c1 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [5.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.2.0...v5.3.0) (2021-11-01) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + + + + + # [5.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v5.1.0...v5.2.0) (2021-10-25) **Note:** Version bump only for package @typescript-eslint/visitor-keys diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index afd4fbd06811..7c95d675ac25 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "5.2.0", + "version": "5.3.0", "description": "Visitor keys used to help traverse the TypeScript-ESTree AST", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "5.2.0", + "@typescript-eslint/types": "5.3.0", "eslint-visitor-keys": "^3.0.0" }, "devDependencies": { 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