Repository: sarbbottam/eslint-find-rules
Pull request #338 (2021-10-10 04:28:02)

[Tests] migrate travis-ci to Github Actions
travis seems dead.


Patch:
diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml
new file mode 100644
index 0000000..9e9c43d
--- /dev/null
+++ b/.github/workflows/node.yml
@@ -0,0 +1,80 @@
+name: 'Tests: node.js'
+
+on: [pull_request, push]
+
+jobs:
+  matrix:
+    runs-on: ubuntu-latest
+    outputs:
+      majors: ${{ steps.set-matrix.outputs.requireds }}
+    steps:
+      - uses: ljharb/actions/node/matrix@main
+        id: set-matrix
+        with:
+          versionsAsRoot: true
+          type: 'majors'
+          preset: '>=10'
+
+  majors:
+    needs: [matrix]
+    name: 'latest majors'
+    runs-on: ubuntu-latest
+
+    strategy:
+      fail-fast: false
+      matrix:
+        node-version: ${{ fromJson(needs.matrix.outputs.majors) }}
+        eslint:
+          - 7
+          - 6
+          - 5
+          - 4
+          - 3
+        include:
+          - node-version: 14
+            eslint: 7.7
+          - node-version: 8
+            eslint: 6
+          - node-version: 8
+            eslint: 5
+          - node-version: 8
+            eslint: 4
+          - node-version: 8
+            eslint: 3
+          - node-version: 6
+            eslint: 5
+            ajv: 5
+          - node-version: 6
+            eslint: 4
+          - node-version: 6
+            eslint: 3
+          - node-version: 4
+            eslint: 4
+          - node-version: 4
+            eslint: 3
+
+    steps:
+      - uses: actions/checkout@v2
+      - uses: ljharb/actions/node/install@main
+        name: 'nvm install ${{ matrix.node-version }} && npm install'
+        with:
+          node-version: ${{ matrix.node-version }}
+          skip-ls-check: true
+      - run: npm install --no-save eslint@${{ matrix.eslint }}
+      - run: npm install --no-save "ajv@${{ matrix.ajv }}"
+        if: ${{ !!matrix.ajv }}
+      - run: npm install --no-save "ajv@5"
+        if: ${{ !matrix.ajv && matrix.eslint == 4 }}
+      - run: npm install --no-save "ajv@6"
+        if: ${{ !matrix.ajv && matrix.eslint == 5 }}
+      - run: npm prune > /dev/null
+      - run: npm ls > /dev/null
+      - run: npm run cover
+      - uses: codecov/codecov-action@v2
+
+  node:
+    name: 'node 10+'
+    needs: [majors]
+    runs-on: ubuntu-latest
+    steps:
+      - run: 'echo tests completed'
diff --git a/.github/workflows/require-allow-edits.yml b/.github/workflows/require-allow-edits.yml
new file mode 100644
index 0000000..549d7b4
--- /dev/null
+++ b/.github/workflows/require-allow-edits.yml
@@ -0,0 +1,12 @@
+name: Require “Allow Edits”
+
+on: [pull_request_target]
+
+jobs:
+  _:
+    name: "Require “Allow Edits”"
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: ljharb/require-allow-edits@main
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 6d36387..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-sudo: false
-language: node_js
-notifications:
-  email: false
-node_js:
-  - '14'
-  - '12'
-  - '10'
-before_install:
-  - nvm install-latest-npm
-before_script:
-  - 'if [ -n "${ESLINT-}" ]; then npm install --no-save "eslint@${ESLINT}"; fi'
-  - 'if [ -n "${AJV-}" ]; then npm install --no-save "ajv@${AJV}"; fi'
-  - npm prune > /dev/null && npm ls > /dev/null
-script:
-  - 'if [ -n "${LINTONLY-}" ]; then npm run lint; else npm run cover && npm run check-coverage; fi'
-after_success:
-  - npm run travis-after-all
-env:
-  matrix:
-   - ESLINT=7
-   - ESLINT=6
-   - ESLINT=5 AJV=6
-   - ESLINT=4 AJV=5
-   - ESLINT=3
-matrix:
-  include:
-    - node_js: "node"
-      env: LINTONLY=true
-    - node_js: "14"
-      env: ESLINT=7.7
-    - node_js: "8"
-      env: ESLINT=6
-    - node_js: "8"
-      env: ESLINT=5 AJV=6
-    - node_js: "8"
-      env: ESLINT=4 AJV=5
-    - node_js: "8"
-      env: ESLINT=3
-    - node_js: "6"
-      env: ESLINT=5 AJV=5
-    - node_js: "6"
-      env: ESLINT=4 AJV=5
-    - node_js: "6"
-      env: ESLINT=3
-    - node_js: "4"
-      env: ESLINT=4 AJV=5
-    - node_js: "4"
-      env: ESLINT=3
diff --git a/package.json b/package.json
index 8854e18..f1745c9 100644
--- a/package.json
+++ b/package.json
@@ -4,18 +4,19 @@
   "description": "Find built-in ESLint rules you don't have in your custom config.",
   "main": "dist/lib/rule-finder.js",
   "scripts": {
-    "cover": "nyc --reporter=lcov --reporter=text --reporter=html npm test",
+    "cover": "nyc --reporter=lcov --reporter=text --reporter=html npm run tests-only",
     "lint": "eslint --ext .js,.json .",
-    "test": "mocha --recursive",
+    "pretest": "npm run lint",
+    "tests-only": "mocha --recursive",
+    "test": "npm run tests-only",
+    "posttest": "aud --production",
     "update-contributors": "all-contributors generate",
     "commit": "git-cz",
     "validate": "npm-run-all --parallel lint cover --sequential check-coverage",
     "check-coverage": "nyc check-coverage --statements 100 --branches 100 --functions 100 --lines 100",
     "prebuild": "rimraf dist",
     "build": "babel src -d dist",
-    "prepublish": "npm run build",
-    "report-coverage": "cat ./coverage/lcov.info | node_modules/.bin/codecov",
-    "travis-after-all": "travis-after-all && npm run report-coverage"
+    "prepublish": "not-in-publish || npm run build"
   },
   "bin": {
     "eslint-find-rules": "dist/bin/find.js",
@@ -30,7 +31,6 @@
   ],
   "license": "MIT",
   "dependencies": {
-    "@eslint/eslintrc": "^0.1.3",
     "cliui": "^3.2.0",
     "eslint-rule-documentation": "^1.0.23",
     "glob": "^7.1.6",
@@ -42,6 +42,7 @@
   "devDependencies": {
     "ajv": "^5 || ^6",
     "all-contributors-cli": "^4.11.2",
+    "aud": "^1.1.5",
     "babel-cli": "^6.26.0",
     "babel-core": "^6.26.3",
     "babel-preset-es2015": "^6.24.1",
@@ -51,14 +52,15 @@
     "eslint": "^3.12.0 || ^4 || ^5 || ^6 || ^7",
     "eslint-plugin-json": "^2.1.2",
     "ghooks": "^2.0.4",
+    "in-publish": "^2.0.1",
     "mocha": "^3.5.3",
     "npm-run-all": "^4.1.5",
     "nyc": "^11.9.0",
     "opt-cli": "^1.6.0",
     "proxyquire": "^1.8.0",
     "rimraf": "^2.7.1",
+    "semver": "^6.3.0",
     "sinon": "^2.4.1",
-    "travis-after-all": "^1.4.5",
     "validate-commit-msg": "^2.14.0"
   },
   "peerDependencies": {
@@ -85,5 +87,8 @@
   "bugs": {
     "url": "https://github.com/sarbbottam/eslint-find-rules/issues"
   },
-  "homepage": "https://github.com/sarbbottam/eslint-find-rules#readme"
+  "homepage": "https://github.com/sarbbottam/eslint-find-rules#readme",
+  "engines": {
+    "node": ">= 4"
+  }
 }


Test patch:
diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml
new file mode 100644
index 0000000..0569f74
--- /dev/null
+++ b/.github/workflows/node-pretest.yml
@@ -0,0 +1,26 @@
+name: 'Tests: pretest/posttest'
+
+on: [pull_request, push]
+
+jobs:
+  pretest:
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v2
+      - uses: ljharb/actions/node/install@main
+        name: 'nvm install lts/* && npm install'
+        with:
+          node-version: 'lts/*'
+      - run: npm run pretest
+
+  # posttest:
+  #   runs-on: ubuntu-latest
+
+  #   steps:
+  #     - uses: actions/checkout@v2
+  #     - uses: ljharb/actions/node/install@main
+  #       name: 'nvm install lts/* && npm install'
+  #       with:
+  #         node-version: 'lts/*'
+  #     - run: npm run posttest
diff --git a/test/lib/rule-finder.js b/test/lib/rule-finder.js
index 85caed4..453dda9 100644
--- a/test/lib/rule-finder.js
+++ b/test/lib/rule-finder.js
@@ -2,10 +2,17 @@ const path = require('path');
 const assert = require('assert');
 const proxyquire = require('proxyquire');
 
+const semver = require('semver');
+const eslintPkg = require('eslint/package.json');
+
 let ModuleResolver;
 try {
-  // eslint 7.12+
-  ModuleResolver = require('@eslint/eslintrc/lib/shared/relative-module-resolver');
+  if (semver.satisfies(eslintPkg.version, '>= 7.12')) {
+    // eslint 7.12+
+    ModuleResolver = require('@eslint/eslintrc/lib/shared/relative-module-resolver');
+  } else {
+    throw { code: 'MODULE_NOT_FOUND' };
+  }
 } catch (err) {
   if (err.code !== 'MODULE_NOT_FOUND') {
     throw err;
@@ -26,8 +33,8 @@ try {
 
 const processCwd = process.cwd;
 
-const eslintVersion = process.env.ESLINT === '3' || process.env.ESLINT === '4' ? 'prior-v5' : 'post-v5';
-const supportsScopedPlugins = process.env.ESLINT !== '3' && process.env.ESLINT !== '4';
+const eslintVersion = semver.satisfies(eslintPkg.version, '< 5') ? 'prior-v5' : 'post-v5';
+const supportsScopedPlugins = semver.satisfies(eslintPkg.version, '>= 5');
 
 const moduleResolver = {
   resolve(name, relative) {
@@ -186,7 +193,7 @@ const usingDeprecatedRulesFile = path.join(process.cwd(), `./test/fixtures/${esl
 
 describe('rule-finder', function() {
   // increase timeout because proxyquire adds a significant delay
-  this.timeout(5000);
+  this.timeout(semver.satisfies(process.version, '> 10') ? 5e3 : (semver.satisfies(process.version, '> 4') ? 20e3 : 30e3));
 
   afterEach(() => {
     process.cwd = processCwd;