From 5f03ab1fc91d055ae3976d0a8a3a9a98b08e9fe2 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 28 Jul 2019 15:20:02 -0400 Subject: [PATCH 1/2] test: ensure integration tests can fail, add vue-sfc --- package.json | 2 +- .../eslint-plugin-tslint/src/rules/config.ts | 2 + tests/integration/docker-compose.yml | 17 +++++ .../test.js.snap | 1 + .../fixtures/vue-sfc/.eslintrc.yml | 21 +++++++ tests/integration/fixtures/vue-sfc/Dockerfile | 17 +++++ tests/integration/fixtures/vue-sfc/Hello.vue | 36 +++++++++++ .../integration/fixtures/vue-sfc/test.js.snap | 63 +++++++++++++++++++ tests/integration/fixtures/vue-sfc/test.sh | 22 +++++++ .../fixtures/vue-sfc/tsconfig.json | 5 ++ tests/integration/run-all-tests.sh | 11 ++++ 11 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 tests/integration/fixtures/vue-sfc/.eslintrc.yml create mode 100644 tests/integration/fixtures/vue-sfc/Dockerfile create mode 100644 tests/integration/fixtures/vue-sfc/Hello.vue create mode 100644 tests/integration/fixtures/vue-sfc/test.js.snap create mode 100755 tests/integration/fixtures/vue-sfc/test.sh create mode 100644 tests/integration/fixtures/vue-sfc/tsconfig.json create mode 100755 tests/integration/run-all-tests.sh diff --git a/package.json b/package.json index 4e630cb4b1bc..98a6c27fc2df 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "generate-contributors": "yarn ts-node ./tools/generate-contributors.ts && yarn all-contributors generate", "format": "prettier --write \"./**/*.{ts,js,json,md}\"", "format-check": "prettier --list-different \"./**/*.{ts,js,json,md}\"", - "integration-tests": "docker-compose -f tests/integration/docker-compose.yml up", + "integration-tests": "./tests/integration/run-all-tests.sh", "kill-integration-test-containers": "docker-compose -f tests/integration/docker-compose.yml down -v --rmi local", "lint": "eslint . --ext .js,.ts", "lint-fix": "eslint . --ext .js,.ts --fix", diff --git a/packages/eslint-plugin-tslint/src/rules/config.ts b/packages/eslint-plugin-tslint/src/rules/config.ts index 7152d21f69b6..a6016c298f80 100644 --- a/packages/eslint-plugin-tslint/src/rules/config.ts +++ b/packages/eslint-plugin-tslint/src/rules/config.ts @@ -70,6 +70,8 @@ export default createRule({ type: 'problem', messages: { failure: '{{message}} (tslint:{{ruleName}})`', + // TODO: Apply the below fix after confirming integration tests fail appropriately in CI + // failure: '{{message}} (tslint:{{ruleName}})', }, schema: [ { diff --git a/tests/integration/docker-compose.yml b/tests/integration/docker-compose.yml index 086f3e76485d..5d10d7661774 100644 --- a/tests/integration/docker-compose.yml +++ b/tests/integration/docker-compose.yml @@ -19,3 +19,20 @@ services: - /usr/eslint-plugin-tslint/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/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/vue-sfc:/usr/linked 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 a4df7d29fe6d..078ddadc167f 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 @@ -24,6 +24,7 @@ Array [ "endLine": 1, "line": 1, "message": "Missing semicolon (tslint:semicolon)", + "messageId": "failure", "nodeType": null, "ruleId": "@typescript-eslint/tslint/config", "severity": 2, diff --git a/tests/integration/fixtures/vue-sfc/.eslintrc.yml b/tests/integration/fixtures/vue-sfc/.eslintrc.yml new file mode 100644 index 000000000000..f20f5baf1746 --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/.eslintrc.yml @@ -0,0 +1,21 @@ +root: true + +parser: 'vue-eslint-parser' + +env: + es6: true + node: true + +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' + +rules: + '@typescript-eslint/no-explicit-any': 'error' diff --git a/tests/integration/fixtures/vue-sfc/Dockerfile b/tests/integration/fixtures/vue-sfc/Dockerfile new file mode 100644 index 000000000000..3b281e624c87 --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/Dockerfile @@ -0,0 +1,17 @@ +FROM node:carbon + +# 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/Hello.vue b/tests/integration/fixtures/vue-sfc/Hello.vue new file mode 100644 index 000000000000..1f5c59ed2dc0 --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/Hello.vue @@ -0,0 +1,36 @@ + + + + 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 000000000000..49bd30cc3897 --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/test.js.snap @@ -0,0 +1,63 @@ +// 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, + }, + ], + "source": " + + + +", + "warningCount": 0, + }, +] +`; diff --git a/tests/integration/fixtures/vue-sfc/test.sh b/tests/integration/fixtures/vue-sfc/test.sh new file mode 100755 index 000000000000..ba89362dcd13 --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/test.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# 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/typescript-estree | tail -1) +npm install $(npm pack /usr/parser | 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 + +# 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.yml /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/tsconfig.json b/tests/integration/fixtures/vue-sfc/tsconfig.json new file mode 100644 index 000000000000..86423f3e4aa2 --- /dev/null +++ b/tests/integration/fixtures/vue-sfc/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "strict": true + } +} \ No newline at end of file diff --git a/tests/integration/run-all-tests.sh b/tests/integration/run-all-tests.sh new file mode 100755 index 000000000000..5b43af062465 --- /dev/null +++ b/tests/integration/run-all-tests.sh @@ -0,0 +1,11 @@ +# Ensure child script failures are propagated +set -e + +# 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 From 19f3e94e5b614cdfff0b2efee6620ba354381da2 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sun, 28 Jul 2019 15:30:58 -0400 Subject: [PATCH 2/2] fix(tslint-plugin): tslint plugin message --- packages/eslint-plugin-tslint/src/rules/config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/eslint-plugin-tslint/src/rules/config.ts b/packages/eslint-plugin-tslint/src/rules/config.ts index a6016c298f80..23ff428111d2 100644 --- a/packages/eslint-plugin-tslint/src/rules/config.ts +++ b/packages/eslint-plugin-tslint/src/rules/config.ts @@ -69,9 +69,7 @@ export default createRule({ }, type: 'problem', messages: { - failure: '{{message}} (tslint:{{ruleName}})`', - // TODO: Apply the below fix after confirming integration tests fail appropriately in CI - // failure: '{{message}} (tslint:{{ruleName}})', + failure: '{{message}} (tslint:{{ruleName}})', }, schema: [ { 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