From 045db2f56474dc71116ee9602e7b46e3acd97946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Fri, 25 Oct 2024 04:53:22 +0200 Subject: [PATCH] feat: drop Node 4, 6, 8, 10, 12, 14 & 16 support BREAKING CHANGE: Requires Node@^18.18.0 || ^20.9.0 || >=21.1.0 --- .github/workflows/native-wsl.yml | 65 ++----------- .github/workflows/node-4+.yml | 160 ------------------------------- .github/workflows/node.yml | 85 ++++++++++++++++ .github/workflows/packages.yml | 5 +- package.json | 2 +- tests/dep-time-travel.sh | 12 +-- 6 files changed, 96 insertions(+), 233 deletions(-) delete mode 100644 .github/workflows/node-4+.yml create mode 100644 .github/workflows/node.yml diff --git a/.github/workflows/native-wsl.yml b/.github/workflows/native-wsl.yml index 5e8318899..360b2873f 100644 --- a/.github/workflows/native-wsl.yml +++ b/.github/workflows/native-wsl.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: os: [windows-2019] - node-version: [18, 16, 14, 12, 10, 8, 6, 4] + node-version: [22, 20, 18] configuration: [wsl, native] steps: @@ -30,80 +30,29 @@ jobs: if: matrix.configuration == 'wsl' env: ESLINT_VERSION: 7 - TRAVIS_NODE_VERSION: ${{ matrix.node-version }} run: | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm nvm install --latest-npm ${{ matrix.node-version }} - if [ ${{ matrix.node-version }} -ge 4 ] && [ ${{ matrix.node-version }} -lt 6 ]; then - npm install eslint@4 --no-save --ignore-scripts - npm install - npm install eslint-import-resolver-typescript@1.0.2 --no-save - npm uninstall @angular-eslint/template-parser @typescript-eslint/parser --no-save - fi - if [ ${{ matrix.node-version }} -ge 6 ] && [ ${{ matrix.node-version }} -lt 7 ]; then - npm install eslint@5 --no-save --ignore-scripts - npm install - npm uninstall @angular-eslint/template-parser --no-save - npm install eslint-import-resolver-typescript@1.0.2 @typescript-eslint/parser@3 --no-save - fi - if [ ${{ matrix.node-version }} -ge 7 ] && [ ${{ matrix.node-version }} -lt 8 ]; then - npm install eslint@6 --no-save --ignore-scripts - npm install - npm install eslint-import-resolver-typescript@1.0.2 typescript-eslint-parser@20 --no-save - npm uninstall @angular-eslint/template-parser --no-save - fi - if [ ${{ matrix.node-version }} -eq 8 ]; then - npm install eslint@6 --no-save --ignore-scripts - npm install - npm uninstall @angular-eslint/template-parser --no-save - npm install @typescript-eslint/parser@3 --no-save - fi - if [ ${{ matrix.node-version }} -gt 8 ] && [ ${{ matrix.node-version }} -lt 10 ]; then - npm install eslint@7 --no-save --ignore-scripts - npm install - npm install @typescript-eslint/parser@3 --no-save - fi - if [ ${{ matrix.node-version }} -ge 10 ] && [ ${{ matrix.node-version }} -lt 12 ]; then - npm install - npm install @typescript-eslint/parser@4 --no-save - fi - if [ ${{ matrix.node-version }} -ge 12 ]; then - npm install - fi + npm install npm run copy-metafiles npm run pretest npm run tests-only - - name: install dependencies for node <= 10 - if: matrix.node-version <= '10' && matrix.configuration == 'native' - run: | - npm install --legacy-peer-deps - npm install eslint@7 --no-save - - - name: Install dependencies for node > 10 - if: matrix.node-version > '10' && matrix.configuration == 'native' + - name: Install dependencies in Native + if: matrix.configuration == 'native' run: npm install - - name: install the latest version of nyc + - name: install the latest version of nyc in Native if: matrix.configuration == 'native' run: npm install nyc@latest --no-save - - name: copy metafiles for node <= 8 - if: matrix.node-version <= 8 && matrix.configuration == 'native' - env: - ESLINT_VERSION: 6 - TRAVIS_NODE_VERSION: ${{ matrix.node-version }} - run: | - npm run copy-metafiles - bash ./tests/dep-time-travel.sh 2>&1 - - name: copy metafiles for Node > 8 - if: matrix.node-version > 8 && matrix.configuration == 'native' + - name: copy metafiles in Native + if: matrix.configuration == 'native' env: ESLINT_VERSION: 7 - TRAVIS_NODE_VERSION: ${{ matrix.node-version }} run: | npm run copy-metafiles bash ./tests/dep-time-travel.sh 2>&1 diff --git a/.github/workflows/node-4+.yml b/.github/workflows/node-4+.yml deleted file mode 100644 index 323c2ad54..000000000 --- a/.github/workflows/node-4+.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: 'Tests: node.js' - -on: [pull_request, push] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -permissions: - contents: read - -jobs: - matrix: - runs-on: ubuntu-latest - outputs: - latest: ${{ steps.set-matrix.outputs.requireds }} - minors: ${{ steps.set-matrix.outputs.optionals }} - steps: - - uses: ljharb/actions/node/matrix@main - id: set-matrix - with: - versionsAsRoot: true - type: majors - preset: '>= 6' # preset: '>=4' # see https://github.com/import-js/eslint-plugin-import/issues/2053 - - latest: - needs: [matrix] - name: 'majors' - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - macos-latest - node-version: ${{ fromJson(needs.matrix.outputs.latest) }} - eslint: - - 9 - - 8 - - 7 - - 6 - - 5 - - 4 - - 3 - - 2 - include: - - node-version: 'lts/*' - os: ubuntu-latest - eslint: 7 - ts-parser: 4 - env: - TS_PARSER: 4 - - node-version: 'lts/*' - os: ubuntu-latest - eslint: 7 - ts-parser: 3 - env: - TS_PARSER: 3 - - node-version: 'lts/*' - os: ubuntu-latest - eslint: 7 - ts-parser: 2 - env: - TS_PARSER: 2 - exclude: - - node-version: 16 - eslint: 9 - - node-version: 15 - eslint: 9 - - node-version: 15 - eslint: 8 - - node-version: 14 - eslint: 9 - - node-version: 13 - eslint: 9 - - node-version: 13 - eslint: 8 - - node-version: 12 - eslint: 9 - - node-version: 11 - eslint: 9 - - node-version: 11 - eslint: 8 - - node-version: 10 - eslint: 9 - - node-version: 10 - eslint: 8 - - node-version: 9 - eslint: 9 - - node-version: 9 - eslint: 8 - - node-version: 9 - eslint: 7 - - node-version: 8 - eslint: 9 - - node-version: 8 - eslint: 8 - - node-version: 8 - eslint: 7 - - node-version: 7 - eslint: 9 - - node-version: 7 - eslint: 8 - - node-version: 7 - eslint: 7 - - node-version: 7 - eslint: 6 - - node-version: 6 - eslint: 9 - - node-version: 6 - eslint: 8 - - node-version: 6 - eslint: 7 - - node-version: 6 - eslint: 6 - - node-version: 5 - eslint: 9 - - node-version: 5 - eslint: 8 - - node-version: 5 - eslint: 7 - - node-version: 5 - eslint: 6 - - node-version: 5 - eslint: 5 - - node-version: 4 - eslint: 9 - - node-version: 4 - eslint: 8 - - node-version: 4 - eslint: 7 - - node-version: 4 - eslint: 6 - - node-version: 4 - eslint: 5 - - steps: - - uses: actions/checkout@v4 - - uses: ljharb/actions/node/install@main - continue-on-error: ${{ matrix.eslint == 4 && matrix.node-version == 4 }} - name: 'nvm install ${{ matrix.node-version }} && npm install, with eslint ${{ matrix.eslint }}' - env: - NPM_CONFIG_LEGACY_PEER_DEPS: ${{ matrix.node-version == 11 && false || true }} - ESLINT_VERSION: ${{ matrix.eslint }} - TRAVIS_NODE_VERSION: ${{ matrix.node-version }} - with: - node-version: ${{ matrix.node-version }} - after_install: npm run copy-metafiles && ./tests/dep-time-travel.sh - skip-ls-check: true - - run: npm run pretest - - run: npm run tests-only - - uses: codecov/codecov-action@v3.1.5 - - node: - name: 'node 4+' - needs: [latest] - runs-on: ubuntu-latest - steps: - - run: 'echo tests completed' diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 000000000..1f8bbf177 --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,85 @@ +name: 'Tests: node.js' + +on: [pull_request, push] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + latest: ${{ steps.set-matrix.outputs.requireds }} + minors: ${{ steps.set-matrix.outputs.optionals }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + versionsAsRoot: true + type: majors + preset: '^18.18.0 || ^20.9.0 || >=21.1.0' + + latest: + needs: [matrix] + name: 'majors' + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + node-version: ${{ fromJson(needs.matrix.outputs.latest) }} + eslint: + - 9 + - 8 + - 7 + - 6 + - 5 + - 4 + - 3 + - 2 + include: + - node-version: 'lts/*' + os: ubuntu-latest + eslint: 7 + env: + TS_PARSER: 4 + - node-version: 'lts/*' + os: ubuntu-latest + eslint: 7 + env: + TS_PARSER: 3 + - node-version: 'lts/*' + os: ubuntu-latest + eslint: 7 + env: + TS_PARSER: 2 + + steps: + - uses: actions/checkout@v4 + - uses: ljharb/actions/node/install@main + continue-on-error: false + name: 'nvm install ${{ matrix.node-version }} && npm install, with eslint ${{ matrix.eslint }}' + env: + NPM_CONFIG_LEGACY_PEER_DEPS: false + ESLINT_VERSION: ${{ matrix.eslint }} + with: + node-version: ${{ matrix.node-version }} + after_install: npm run copy-metafiles && ./tests/dep-time-travel.sh + skip-ls-check: true + - run: npm run pretest + - run: npm run tests-only + - uses: codecov/codecov-action@v3.1.5 + + node: + name: 'node 18+' + needs: [latest] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index f73f8e18f..db61d30b0 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -20,7 +20,7 @@ jobs: id: set-matrix with: type: 'majors' - preset: '>= 6' # preset: '>=4' # see https://github.com/import-js/eslint-plugin-import/issues/2053 + preset: '^18.18.0 || ^20.9.0 || >=21.1.0' versionsAsRoot: true tests: @@ -46,9 +46,8 @@ jobs: - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' env: - NPM_CONFIG_LEGACY_PEER_DEPS: ${{ matrix.node-version == 11 && false || true }} + NPM_CONFIG_LEGACY_PEER_DEPS: false ESLINT_VERSION: ${{ matrix.eslint }} - TRAVIS_NODE_VERSION: ${{ matrix.node-version }} with: node-version: ${{ matrix.node-version }} after_install: npm run copy-metafiles && ./tests/dep-time-travel.sh && cd ${{ matrix.package }} && npm install diff --git a/package.json b/package.json index 7852506bd..5f9f10acc 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "2.31.0", "description": "Import with sanity.", "engines": { - "node": ">=4" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "main": "lib/index.js", "directories": { diff --git a/tests/dep-time-travel.sh b/tests/dep-time-travel.sh index 665ca1ccf..ceb95be0e 100755 --- a/tests/dep-time-travel.sh +++ b/tests/dep-time-travel.sh @@ -2,7 +2,7 @@ # expected: ESLINT_VERSION numeric env var -echo "installing ${ESLINT_VERSION} in node ${TRAVIS_NODE_VERSION} with TS parser ${TS_PARSER:-default}..." +echo "installing ${ESLINT_VERSION} with TS parser ${TS_PARSER:-default}..." export NPM_CONFIG_LEGACY_PEER_DEPS=true @@ -19,10 +19,6 @@ if [[ -n "$TS_PARSER" ]]; then # if TS parser is manually set, always use it elif [[ "$ESLINT_VERSION" -lt "5" ]]; then # completely remove the new TypeScript parser for ESLint < v5 echo "Removing @typescript-eslint/parser..." npm uninstall --no-save @typescript-eslint/parser -elif [[ "$TRAVIS_NODE_VERSION" -lt "10" ]]; then # TS parser 3 requires node 10+ - npm i --no-save "@typescript-eslint/parser@3" -elif [[ "$TRAVIS_NODE_VERSION" -lt "12" ]]; then # TS parser 4 requires node 12+ - npm i --no-save "@typescript-eslint/parser@4" fi # use these alternate TypeScript dependencies for ESLint < v4 @@ -37,12 +33,6 @@ elif [[ "$ESLINT_VERSION" -lt "7" ]]; then npm i --no-save typescript-eslint-parser@20 fi -# typescript-eslint-parser 1.1.1+ is not compatible with node 6 -if [[ "$TRAVIS_NODE_VERSION" -lt "8" ]]; then - echo "Downgrading eslint-import-resolver-typescript..." - npm i --no-save eslint-import-resolver-typescript@1.0.2 -fi - if [ "${ESLINT_VERSION}" = '8' ]; then # This is a workaround for the crash in the initial processing of the ESLint class. echo "Installing self"