From 31fc5039ed919e1515fda673c186d5c83eb5beb3 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Mon, 25 May 2020 13:41:42 -0700 Subject: [PATCH] fix: regression for eslint v6 (#2105) --- .prettierignore | 1 - .../src/ts-eslint/ESLint.ts | 12 +- tests/integration/README.md | 2 + tests/integration/docker-compose.yml | 19 ++ .../fixtures/eslint-v6/.eslintrc.js | 12 + .../integration/fixtures/eslint-v6/Dockerfile | 17 + tests/integration/fixtures/eslint-v6/index.ts | 1 + .../fixtures/eslint-v6/test.js.snap | 28 ++ tests/integration/fixtures/eslint-v6/test.sh | 22 ++ .../fixtures/eslint-v6/tsconfig.json | 5 + tests/integration/fixtures/markdown/Doc.md | 8 +- .../fixtures/markdown/test.js.snap | 298 ++++++++++++++++++ tests/integration/fixtures/markdown/test.sh | 3 +- .../fixtures/markdown/tsconfig.json | 8 +- .../index.ts | 2 +- .../test.js.snap | 82 +++++ .../test.sh | 1 + .../.eslintrc.js | 61 ++-- .../index.ts | 1 + .../test.js.snap | 15 +- .../test.sh | 1 + .../tsconfig.json | 8 +- .../integration/fixtures/vue-jsx/.eslintrc.js | 4 +- .../integration/fixtures/vue-jsx/test.js.snap | 88 ++++++ tests/integration/fixtures/vue-jsx/test.sh | 12 +- .../fixtures/vue-jsx/tsconfig.json | 10 +- .../integration/fixtures/vue-sfc/.eslintrc.js | 4 +- .../integration/fixtures/vue-sfc/test.js.snap | 97 ++++++ tests/integration/fixtures/vue-sfc/test.sh | 12 +- .../fixtures/vue-sfc/tsconfig.json | 10 +- tests/integration/run-all-tests.sh | 7 +- .../lint-real-repo/install-local-packages.sh | 3 + 32 files changed, 764 insertions(+), 90 deletions(-) create mode 100644 tests/integration/fixtures/eslint-v6/.eslintrc.js create mode 100644 tests/integration/fixtures/eslint-v6/Dockerfile create mode 100644 tests/integration/fixtures/eslint-v6/index.ts create mode 100644 tests/integration/fixtures/eslint-v6/test.js.snap create mode 100755 tests/integration/fixtures/eslint-v6/test.sh create mode 100644 tests/integration/fixtures/eslint-v6/tsconfig.json create mode 100644 tests/integration/fixtures/markdown/test.js.snap create mode 100644 tests/integration/fixtures/recommended-does-not-require-program/test.js.snap create mode 100644 tests/integration/fixtures/vue-jsx/test.js.snap create mode 100644 tests/integration/fixtures/vue-sfc/test.js.snap diff --git a/.prettierignore b/.prettierignore index aed86e816d4..2578aad23b7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,7 +3,6 @@ **/dist **/coverage **/shared-fixtures -**/tests/integration/fixtures/**/* **/.vscode **/.nyc_output packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js diff --git a/packages/experimental-utils/src/ts-eslint/ESLint.ts b/packages/experimental-utils/src/ts-eslint/ESLint.ts index c90978bb115..a0d7ec2b944 100644 --- a/packages/experimental-utils/src/ts-eslint/ESLint.ts +++ b/packages/experimental-utils/src/ts-eslint/ESLint.ts @@ -341,6 +341,16 @@ namespace ESLint { } } +// We want to export this class always so it's easy for end users to consume. +// However on ESLint v6, this class will not exist, so we provide a fallback to make it clear +// The only users of this should be users scripting ESLint locally, so _they_ should have the correct version installed. +const _ESLint = (ESLintESLint ?? + function (): void { + throw new Error( + 'Attempted to construct an ESLint instance on less than ESLint v7.0.0', + ); + }) as typeof ESLintBase; + /** * The ESLint class is the primary class to use in Node.js applications. * This class depends on the Node.js fs module and the file system, so you cannot use it in browsers. @@ -349,6 +359,6 @@ namespace ESLint { * * @since 7.0.0 */ -class ESLint extends (ESLintESLint as typeof ESLintBase) {} +class ESLint extends _ESLint {} export { ESLint }; diff --git a/tests/integration/README.md b/tests/integration/README.md index c0aa0b97643..a1f39ca6eb2 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -16,3 +16,5 @@ These tests are setup to run within docker containers to ensure that each test i 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. + +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. diff --git a/tests/integration/docker-compose.yml b/tests/integration/docker-compose.yml index a92dff5e090..a65f23c6b38 100644 --- a/tests/integration/docker-compose.yml +++ b/tests/integration/docker-compose.yml @@ -97,3 +97,22 @@ services: - /usr/eslint-plugin/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 + # 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 new file mode 100644 index 00000000000..ad9ed940298 --- /dev/null +++ b/tests/integration/fixtures/eslint-v6/.eslintrc.js @@ -0,0 +1,12 @@ +module.exports = { + root: true, + // Local version of @typescript-eslint/parser + parser: '@typescript-eslint/parser', + plugins: [ + // Local version of @typescript-eslint/eslint-plugin + '@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 new file mode 100644 index 00000000000..027ff085a6c --- /dev/null +++ b/tests/integration/fixtures/eslint-v6/Dockerfile @@ -0,0 +1,17 @@ +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/index.ts b/tests/integration/fixtures/eslint-v6/index.ts new file mode 100644 index 00000000000..126ac330a10 --- /dev/null +++ b/tests/integration/fixtures/eslint-v6/index.ts @@ -0,0 +1 @@ +const noSemi: any = true; diff --git a/tests/integration/fixtures/eslint-v6/test.js.snap b/tests/integration/fixtures/eslint-v6/test.js.snap new file mode 100644 index 00000000000..350194ef759 --- /dev/null +++ b/tests/integration/fixtures/eslint-v6/test.js.snap @@ -0,0 +1,28 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it should produce the expected lint ouput 1`] = ` +Array [ + Object { + "errorCount": 1, + "filePath": "/usr/linked/index.ts", + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "messages": Array [ + Object { + "column": 15, + "endColumn": 18, + "endLine": 1, + "line": 1, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "severity": 2, + }, + ], + "source": "const noSemi: any = true; +", + "warningCount": 0, + }, +] +`; diff --git a/tests/integration/fixtures/eslint-v6/test.sh b/tests/integration/fixtures/eslint-v6/test.sh new file mode 100755 index 00000000000..d1cc755c58a --- /dev/null +++ b/tests/integration/fixtures/eslint-v6/test.sh @@ -0,0 +1,22 @@ +#!/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/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/eslint-v6/tsconfig.json b/tests/integration/fixtures/eslint-v6/tsconfig.json new file mode 100644 index 00000000000..aee0ec940fc --- /dev/null +++ b/tests/integration/fixtures/eslint-v6/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strict": true + } +} diff --git a/tests/integration/fixtures/markdown/Doc.md b/tests/integration/fixtures/markdown/Doc.md index 0d6eabe455e..e894566fe1e 100644 --- a/tests/integration/fixtures/markdown/Doc.md +++ b/tests/integration/fixtures/markdown/Doc.md @@ -1,6 +1,7 @@ Some extra text to verify that the markdown plugin is ignoring anything that is not a code block. expected no-console error: + ```jsx import { Button } from 'antd'; @@ -20,6 +21,7 @@ function MyComp() { expected no-explicit-any error: expected no-console error: + ```jsx import { Button } from 'antd'; @@ -38,6 +40,7 @@ function MyComp(): any { ``` expected no-console error: + ```js function foo() { console.log('test'); @@ -46,24 +49,25 @@ function foo() { expected no-explicit-any error: expected no-console error: + ```js function foo(): any { console.log('test'); } ``` - expected no-explicit-any error: expected no-console error: + ```javascript function foo(): any { console.log('test'); } ``` - expected no-explicit-any error: expected no-console error: + ```node function foo(): any { console.log('test'); diff --git a/tests/integration/fixtures/markdown/test.js.snap b/tests/integration/fixtures/markdown/test.js.snap new file mode 100644 index 00000000000..8663838f7ed --- /dev/null +++ b/tests/integration/fixtures/markdown/test.js.snap @@ -0,0 +1,298 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it should produce the expected lint ouput 1`] = ` +Array [ + Object { + "errorCount": 10, + "filePath": "/usr/linked/Doc.md", + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "messages": Array [ + Object { + "column": 3, + "endColumn": 14, + "endLine": 9, + "line": 9, + "message": "Unexpected console statement.", + "messageId": "unexpected", + "nodeType": "MemberExpression", + "ruleId": "no-console", + "severity": 2, + }, + Object { + "column": 20, + "endColumn": 23, + "endLine": 28, + "line": 28, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "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 [ + 51, + 54, + ], + "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 [ + 51, + 54, + ], + "text": "never", + }, + "messageId": "suggestNever", + }, + ], + }, + Object { + "column": 3, + "endColumn": 14, + "endLine": 29, + "line": 29, + "message": "Unexpected console statement.", + "messageId": "unexpected", + "nodeType": "MemberExpression", + "ruleId": "no-console", + "severity": 2, + }, + Object { + "column": 3, + "endColumn": 14, + "endLine": 46, + "line": 46, + "message": "Unexpected console statement.", + "messageId": "unexpected", + "nodeType": "MemberExpression", + "ruleId": "no-console", + "severity": 2, + }, + Object { + "column": 17, + "endColumn": 20, + "endLine": 54, + "line": 54, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "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 [ + 16, + 19, + ], + "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 [ + 16, + 19, + ], + "text": "never", + }, + "messageId": "suggestNever", + }, + ], + }, + Object { + "column": 3, + "endColumn": 14, + "endLine": 55, + "line": 55, + "message": "Unexpected console statement.", + "messageId": "unexpected", + "nodeType": "MemberExpression", + "ruleId": "no-console", + "severity": 2, + }, + Object { + "column": 17, + "endColumn": 20, + "endLine": 63, + "line": 63, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "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 [ + 16, + 19, + ], + "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 [ + 16, + 19, + ], + "text": "never", + }, + "messageId": "suggestNever", + }, + ], + }, + Object { + "column": 3, + "endColumn": 14, + "endLine": 64, + "line": 64, + "message": "Unexpected console statement.", + "messageId": "unexpected", + "nodeType": "MemberExpression", + "ruleId": "no-console", + "severity": 2, + }, + Object { + "column": 17, + "endColumn": 20, + "endLine": 72, + "line": 72, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "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 [ + 16, + 19, + ], + "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 [ + 16, + 19, + ], + "text": "never", + }, + "messageId": "suggestNever", + }, + ], + }, + Object { + "column": 3, + "endColumn": 14, + "endLine": 73, + "line": 73, + "message": "Unexpected console statement.", + "messageId": "unexpected", + "nodeType": "MemberExpression", + "ruleId": "no-console", + "severity": 2, + }, + ], + "source": "Some extra text to verify that the markdown plugin is ignoring anything that is not a code block. + +expected no-console error: + +\`\`\`jsx +import { Button } from 'antd'; + +function MyComp() { + console.log('test'); + return ( +
+ + + + + +
+ ); +} +\`\`\` + +expected no-explicit-any error: +expected no-console error: + +\`\`\`jsx +import { Button } from 'antd'; + +function MyComp(): any { + console.log('test'); + return ( +
+ + + + + +
+ ); +} +\`\`\` + +expected no-console error: + +\`\`\`js +function foo() { + console.log('test'); +} +\`\`\` + +expected no-explicit-any error: +expected no-console error: + +\`\`\`js +function foo(): any { + console.log('test'); +} +\`\`\` + +expected no-explicit-any error: +expected no-console error: + +\`\`\`javascript +function foo(): any { + console.log('test'); +} +\`\`\` + +expected no-explicit-any error: +expected no-console error: + +\`\`\`node +function foo(): any { + console.log('test'); +} +\`\`\` +", + "usedDeprecatedRules": Array [], + "warningCount": 0, + }, +] +`; diff --git a/tests/integration/fixtures/markdown/test.sh b/tests/integration/fixtures/markdown/test.sh index 356156f60f7..9ff7a57b68c 100755 --- a/tests/integration/fixtures/markdown/test.sh +++ b/tests/integration/fixtures/markdown/test.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -exuo pipefail # Generate the package.json to use node /usr/utils/generate-package-json.js @@ -12,7 +13,7 @@ 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 vue-eslint-parser (this may break us occassionally, but it's probably good to get that feedback early) +# 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 diff --git a/tests/integration/fixtures/markdown/tsconfig.json b/tests/integration/fixtures/markdown/tsconfig.json index 45234bf35aa..eb32eba20a3 100644 --- a/tests/integration/fixtures/markdown/tsconfig.json +++ b/tests/integration/fixtures/markdown/tsconfig.json @@ -1,6 +1,6 @@ { - "compilerOptions": { - "strict": true - }, - "include": [] + "compilerOptions": { + "strict": true + }, + "include": [] } diff --git a/tests/integration/fixtures/recommended-does-not-require-program/index.ts b/tests/integration/fixtures/recommended-does-not-require-program/index.ts index 838b04b9475..cf187492f17 100644 --- a/tests/integration/fixtures/recommended-does-not-require-program/index.ts +++ b/tests/integration/fixtures/recommended-does-not-require-program/index.ts @@ -1 +1 @@ -var foo = true +var foo: any = true; diff --git a/tests/integration/fixtures/recommended-does-not-require-program/test.js.snap b/tests/integration/fixtures/recommended-does-not-require-program/test.js.snap new file mode 100644 index 00000000000..b313deb408b --- /dev/null +++ b/tests/integration/fixtures/recommended-does-not-require-program/test.js.snap @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it should produce the expected lint ouput 1`] = ` +Array [ + Object { + "errorCount": 1, + "filePath": "/usr/linked/index.ts", + "fixableErrorCount": 1, + "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, + "endLine": 1, + "line": 1, + "message": "'foo' is assigned a value but never used.", + "messageId": "unusedVar", + "nodeType": "Identifier", + "ruleId": "@typescript-eslint/no-unused-vars", + "severity": 1, + }, + Object { + "column": 10, + "endColumn": 13, + "endLine": 1, + "line": 1, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "severity": 1, + "suggestions": Array [ + Object { + "desc": "Use \`unknown\` instead, this will force you to explicitly, and safely assert the type is correct.", + "fix": Object { + "range": Array [ + 9, + 12, + ], + "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 [ + 9, + 12, + ], + "text": "never", + }, + "messageId": "suggestNever", + }, + ], + }, + ], + "source": "var foo: any = true; +", + "usedDeprecatedRules": Array [], + "warningCount": 2, + }, +] +`; diff --git a/tests/integration/fixtures/recommended-does-not-require-program/test.sh b/tests/integration/fixtures/recommended-does-not-require-program/test.sh index 9abb264733d..9e9b2a6917b 100755 --- a/tests/integration/fixtures/recommended-does-not-require-program/test.sh +++ b/tests/integration/fixtures/recommended-does-not-require-program/test.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -exuo pipefail # Generate the package.json to use node /usr/utils/generate-package-json.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 3caad1ed427..0409a42c42b 100644 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.js +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/.eslintrc.js @@ -1,38 +1,33 @@ module.exports = { - "root": true, + 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" + 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', ], - "env": { - "es6": true, - "node": true + env: { + es6: true, + node: true, }, - "extends": [ - "plugin:@typescript-eslint/recommended" - ], - "parserOptions": { - "sourceType": "module", - "ecmaFeatures": { - "jsx": false - }, - "project": "/usr/linked/tsconfig.json" + extends: ['plugin:@typescript-eslint/recommended'], + parserOptions: { + sourceType: 'module', + ecmaFeatures: { + jsx: false, + }, + project: '/usr/linked/tsconfig.json', + }, + rules: { + '@typescript-eslint/tslint/config': [ + 'error', + { + rules: { + semicolon: [true, 'always'], + }, + }, + ], }, - "rules": { - "@typescript-eslint/tslint/config": [ - "error", - { - "rules": { - "semicolon": [ - true, - "always" - ] - } - } - ] - } -} +}; diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/index.ts b/tests/integration/fixtures/typescript-and-tslint-plugins-together/index.ts index 9c39b2d32a7..8812117dbb2 100644 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/index.ts +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/index.ts @@ -1 +1,2 @@ +// prettier-ignore const noSemi = true 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 index 26482bf124b..23e113677cc 100644 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.js.snap @@ -11,8 +11,8 @@ Array [ Object { "column": 7, "endColumn": 13, - "endLine": 1, - "line": 1, + "endLine": 2, + "line": 2, "message": "'noSemi' is assigned a value but never used.", "messageId": "unusedVar", "nodeType": "Identifier", @@ -22,15 +22,15 @@ Array [ Object { "column": 20, "endColumn": 20, - "endLine": 1, + "endLine": 2, "fix": Object { "range": Array [ - 19, - 19, + 38, + 38, ], "text": ";", }, - "line": 1, + "line": 2, "message": "Missing semicolon (tslint:semicolon)", "messageId": "failure", "nodeType": null, @@ -38,7 +38,8 @@ Array [ "severity": 2, }, ], - "source": "const noSemi = true + "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 index b634d531d5e..7afab784b6c 100755 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/test.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -exuo pipefail # Generate the package.json to use node /usr/utils/generate-package-json.js diff --git a/tests/integration/fixtures/typescript-and-tslint-plugins-together/tsconfig.json b/tests/integration/fixtures/typescript-and-tslint-plugins-together/tsconfig.json index 86423f3e4aa..aee0ec940fc 100644 --- a/tests/integration/fixtures/typescript-and-tslint-plugins-together/tsconfig.json +++ b/tests/integration/fixtures/typescript-and-tslint-plugins-together/tsconfig.json @@ -1,5 +1,5 @@ { - "compilerOptions": { - "strict": true - } -} \ No newline at end of file + "compilerOptions": { + "strict": true + } +} diff --git a/tests/integration/fixtures/vue-jsx/.eslintrc.js b/tests/integration/fixtures/vue-jsx/.eslintrc.js index c9d88fd01e9..0881ee92835 100644 --- a/tests/integration/fixtures/vue-jsx/.eslintrc.js +++ b/tests/integration/fixtures/vue-jsx/.eslintrc.js @@ -5,9 +5,7 @@ module.exports = { es6: true, node: true, }, - extends: [ - 'plugin:vue/essential', - ], + extends: ['plugin:vue/essential'], parserOptions: { // Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser', diff --git a/tests/integration/fixtures/vue-jsx/test.js.snap b/tests/integration/fixtures/vue-jsx/test.js.snap new file mode 100644 index 00000000000..23764ebfea9 --- /dev/null +++ b/tests/integration/fixtures/vue-jsx/test.js.snap @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it should produce the expected lint ouput 1`] = ` +Array [ + Object { + "errorCount": 1, + "filePath": "/usr/linked/Jsx.vue", + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "messages": Array [ + Object { + "column": 17, + "endColumn": 20, + "endLine": 17, + "line": 17, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "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 [ + 390, + 393, + ], + "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 [ + 390, + 393, + ], + "text": "never", + }, + "messageId": "suggestNever", + }, + ], + }, + ], + "source": " +", + "usedDeprecatedRules": Array [], + "warningCount": 0, + }, +] +`; diff --git a/tests/integration/fixtures/vue-jsx/test.sh b/tests/integration/fixtures/vue-jsx/test.sh index a484c2625e7..7e03aa3dc15 100755 --- a/tests/integration/fixtures/vue-jsx/test.sh +++ b/tests/integration/fixtures/vue-jsx/test.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -exuo pipefail # Generate the package.json to use node /usr/utils/generate-package-json.js @@ -12,15 +13,10 @@ 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 vue-eslint-parser (this may break us occassionally, but it's probably good to get that feedback early) -npm install vue-eslint-parser@latest - -# Install the latest eslint-plugin-vue (this may break us occassionally, but it's probably good to get that feedback early) -npm install eslint-plugin-vue@latest - +# 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 -npm install vue-property-decorator@latest +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) diff --git a/tests/integration/fixtures/vue-jsx/tsconfig.json b/tests/integration/fixtures/vue-jsx/tsconfig.json index 861b7d99bed..f49818af019 100644 --- a/tests/integration/fixtures/vue-jsx/tsconfig.json +++ b/tests/integration/fixtures/vue-jsx/tsconfig.json @@ -1,8 +1,6 @@ { - "compilerOptions": { - "strict": true - }, - "include": [ - "*.vue" - ] + "compilerOptions": { + "strict": true + }, + "include": ["*.vue"] } diff --git a/tests/integration/fixtures/vue-sfc/.eslintrc.js b/tests/integration/fixtures/vue-sfc/.eslintrc.js index 7be44347c59..2fd3c51e7c2 100644 --- a/tests/integration/fixtures/vue-sfc/.eslintrc.js +++ b/tests/integration/fixtures/vue-sfc/.eslintrc.js @@ -5,9 +5,7 @@ module.exports = { es6: true, node: true, }, - extends: [ - 'plugin:vue/essential', - ], + extends: ['plugin:vue/essential'], parserOptions: { // Local version of @typescript-eslint/parser parser: '@typescript-eslint/parser', diff --git a/tests/integration/fixtures/vue-sfc/test.js.snap b/tests/integration/fixtures/vue-sfc/test.js.snap new file mode 100644 index 00000000000..755700fe36b --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/test.js.snap @@ -0,0 +1,97 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`it should produce the expected lint ouput 1`] = ` +Array [ + Object { + "errorCount": 1, + "filePath": "/usr/linked/Hello.vue", + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "messages": Array [ + Object { + "column": 29, + "endColumn": 32, + "endLine": 31, + "line": 31, + "message": "Unexpected any. Specify a different type.", + "messageId": "unexpectedAny", + "nodeType": "TSAnyKeyword", + "ruleId": "@typescript-eslint/no-explicit-any", + "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 [ + 708, + 711, + ], + "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 [ + 708, + 711, + ], + "text": "never", + }, + "messageId": "suggestNever", + }, + ], + }, + ], + "source": " + + + +", + "usedDeprecatedRules": Array [], + "warningCount": 0, + }, + Object { + "errorCount": 0, + "filePath": "/usr/linked/World.vue", + "fixableErrorCount": 0, + "fixableWarningCount": 0, + "messages": Array [], + "usedDeprecatedRules": Array [], + "warningCount": 0, + }, +] +`; diff --git a/tests/integration/fixtures/vue-sfc/test.sh b/tests/integration/fixtures/vue-sfc/test.sh index a484c2625e7..7e03aa3dc15 100755 --- a/tests/integration/fixtures/vue-sfc/test.sh +++ b/tests/integration/fixtures/vue-sfc/test.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -exuo pipefail # Generate the package.json to use node /usr/utils/generate-package-json.js @@ -12,15 +13,10 @@ 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 vue-eslint-parser (this may break us occassionally, but it's probably good to get that feedback early) -npm install vue-eslint-parser@latest - -# Install the latest eslint-plugin-vue (this may break us occassionally, but it's probably good to get that feedback early) -npm install eslint-plugin-vue@latest - +# 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 -npm install vue-property-decorator@latest +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) diff --git a/tests/integration/fixtures/vue-sfc/tsconfig.json b/tests/integration/fixtures/vue-sfc/tsconfig.json index 861b7d99bed..f49818af019 100644 --- a/tests/integration/fixtures/vue-sfc/tsconfig.json +++ b/tests/integration/fixtures/vue-sfc/tsconfig.json @@ -1,8 +1,6 @@ { - "compilerOptions": { - "strict": true - }, - "include": [ - "*.vue" - ] + "compilerOptions": { + "strict": true + }, + "include": ["*.vue"] } diff --git a/tests/integration/run-all-tests.sh b/tests/integration/run-all-tests.sh index 8964e319869..eccb4e2e157 100755 --- a/tests/integration/run-all-tests.sh +++ b/tests/integration/run-all-tests.sh @@ -1,5 +1,5 @@ -# Ensure child script failures are propagated -set -e +#!/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 @@ -18,3 +18,6 @@ docker-compose -f tests/integration/docker-compose.yml up --build --abort-on-con # 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/performance/fixtures/lint-real-repo/install-local-packages.sh b/tests/performance/fixtures/lint-real-repo/install-local-packages.sh index f38459f3455..0807e303b89 100755 --- a/tests/performance/fixtures/lint-real-repo/install-local-packages.sh +++ b/tests/performance/fixtures/lint-real-repo/install-local-packages.sh @@ -1,3 +1,6 @@ +#!/bin/bash +set -exuo pipefail + # This script should be run by attaching a shell to the running docker # container, and then running `../linked/install-local-packages.sh` from # that shell.