From 2df66e426a3b771af2b67b59e8172ad0c29eb5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 9 May 2020 00:40:46 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=92=20update=20CI=20and=20deps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 +- .github/workflows/CI.yml | 86 ++++++++++++++++++------------------ package.json | 6 +-- scripts/ci-install-eslint.js | 47 ++++++++++++++++++++ test/core-rules.js | 17 ++++++- 5 files changed, 110 insertions(+), 48 deletions(-) create mode 100644 scripts/ci-install-eslint.js diff --git a/.gitattributes b/.gitattributes index e561ec1e..fa8984c7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,2 @@ -*.ts eol=lf +* text=auto eol=lf /test/fixtures/crlf.vue eol=crlf diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9ea8903c..c9b501be 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,45 +12,57 @@ jobs: name: Lint runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v1 - with: - fetch-depth: 1 - - name: Checkout submodules - run: git submodule update --init - - name: Install Node.js - uses: actions/setup-node@v1 - with: - node-version: 12 - - name: Install Packages - run: npm install - - name: Lint - run: npm run -s lint + - name: Checkout + uses: actions/checkout@v2 + - name: Checkout submodules + run: git submodule update --init + - name: Install Node.js + uses: actions/setup-node@v1 + with: + node-version: 14 + - name: Install Packages + run: npm install + - name: Lint + run: npm run -s lint test: name: Test - strategy: matrix: - eslint: [6, 5] - node: [13, 12, 10, 8, "8.10.0"] - exclude: - # Run ESLint 5 on only the LTS. - - node: 13 - eslint: 5 - - node: 10 - eslint: 5 - - node: 8 - eslint: 5 - - node: "8.10.0" - eslint: 5 + eslint: [7] + node: [14] + os: [ubuntu-latest] + include: + # On other platforms + - eslint: 7 + node: 14 + os: windows-latest + - eslint: 7 + node: 14 + os: macos-latest + # On old Node.js versions + - eslint: 7 + node: 12 + os: ubuntu-latest + - eslint: 7 + node: 10 + os: ubuntu-latest + # On old ESLint versions + - eslint: 6 + node: 14 + os: ubuntu-latest + - eslint: 5 + node: 14 + os: ubuntu-latest + # On the minimum supported ESLint/Node.js version + - eslint: 5 + node: 8.10.0 + os: ubuntu-latest - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} steps: - name: Checkout - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v2 - name: Checkout submodules run: git submodule update --init - name: Install Node.js v${{ matrix.node }} @@ -60,17 +72,7 @@ jobs: - name: Install Packages run: npm install - name: Install ESLint v${{ matrix.eslint }} - run: | - if [ ${{ matrix.eslint }} -eq 6 ]; then - cd test/fixtures/eslint - npm install - else - npm install --no-save eslint@5.16.0 - cd test/fixtures/eslint - git checkout v5.16.0 - npm install eslint-utils@1.4.0 - npm install - fi + run: node scripts/ci-install-eslint ${{ matrix.eslint }} - name: Build run: npm run -s build - name: Test diff --git a/package.json b/package.json index 6705f0a9..2195ace8 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "debug": "^4.1.1", "eslint-scope": "^5.0.0", "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", + "espree": "^7.0.0", "esquery": "^1.0.1", "lodash": "^4.17.15" }, @@ -27,13 +27,13 @@ "@types/lodash": "^4.14.120", "@types/mocha": "^5.2.4", "@types/node": "^10.12.21", - "@typescript-eslint/parser": "^1.2.0", + "@typescript-eslint/parser": "^2.31.0", "babel-eslint": "^10.0.1", "chokidar": "^2.0.4", "codecov": "^3.1.0", "cross-spawn": "^6.0.5", "dts-bundle": "^0.7.3", - "eslint": "^6.1.0", + "eslint": "^7.0.0", "fs-extra": "^7.0.1", "mocha": "^6.1.4", "npm-run-all": "^4.1.5", diff --git a/scripts/ci-install-eslint.js b/scripts/ci-install-eslint.js new file mode 100644 index 00000000..7bde2b54 --- /dev/null +++ b/scripts/ci-install-eslint.js @@ -0,0 +1,47 @@ +"use strict" + +const { spawn } = require("child_process") + +function cd(path) { + console.log("$ cd %s", path) + process.chdir(path) +} + +function sh(command) { + console.log("$ %s", command) + return new Promise((resolve, reject) => { + spawn(command, [], { shell: true, stdio: "inherit" }) + .on("error", reject) + .on("exit", exitCode => { + if (exitCode) { + reject(new Error(`Exit with non-zero ${exitCode}`)) + } else { + resolve() + } + }) + }) +} + +;(async function main() { + const requestedVersion = process.argv[2] + const requestedVersionSpec = /^\d+\.\d+\.\d+$/u.test(requestedVersion) + ? requestedVersion + : `^${requestedVersion}` + + // Install ESLint of the requested version + await sh(`npm install eslint@${requestedVersionSpec}`) + + // Install ESLint submodule of the requested version + const installedVersion = require("eslint").CLIEngine.version + cd("test/fixtures/eslint") + if (!installedVersion.startsWith("7.")) { + await sh(`git checkout v${installedVersion}`) + } + if (installedVersion.startsWith("5.")) { + await sh("npm install eslint-utils@1.4.0") + } + await sh("npm install") +})().catch(error => { + console.error(error) + process.exitCode = 1 +}) diff --git a/test/core-rules.js b/test/core-rules.js index 8de6116d..afd28040 100644 --- a/test/core-rules.js +++ b/test/core-rules.js @@ -44,6 +44,19 @@ const EXCEPTIONS = new Set([ const originalRun = RuleTester.prototype.run const processed = new Set() +/** + * Check if the code should be skipped or not. + * The following code should be skipped. + * - includes shebang + * - includes syntax error -- some tests in old ESLint contains syntax error. + * Acorn has fixed to catch the syntax errors in a minor release, so those + * tests go to fail. + * @param {string} code The test code. + */ +function codeShouldBeSkipped(code) { + return code.startsWith("#!") || code.includes("await async") +} + /** * Wrap the given code with a `