Skip to content

Commit

Permalink
fix: don't add rules if they're not available
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Nov 14, 2022
1 parent 9225766 commit 8ed466a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ on:

jobs:
lint:
name: ⬣ Lint
name: ⬣ Lint (ESLint@${{ matrix.eslint }})
strategy:
matrix:
eslint: [6, 7]
runs-on: ubuntu-latest
steps:
- name: 🛑 Cancel Previous Runs
Expand All @@ -32,6 +35,9 @@ jobs:
- name: 📥 Install dependencies
run: npm install

- name: 📥 Install ESLint v${{ matrix.eslint }}
run: npm install --save-dev eslint@${{ matrix.eslint }}

- name: ▶️ Run lint script
run: npm run lint

Expand Down
20 changes: 13 additions & 7 deletions lib/configs/_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
*/
"use strict"

const { ESLint, version: ESLintVersion } = require("eslint")

const version = ESLint.version || ESLintVersion
const isESLint7 = version.startsWith("7")

/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
plugins: ["@eslint-community/mysticatea"],
Expand All @@ -27,7 +33,7 @@ module.exports = {
"consistent-return": "error",
curly: "error",
"default-case": "error",
"default-case-last": "error",
...(isESLint7 ? { "default-case-last": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"default-param-last": "error",
"dot-notation": "error",
eqeqeq: ["error", "always", { null: "ignore" }],
Expand Down Expand Up @@ -93,7 +99,7 @@ module.exports = {
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-loss-of-precision": "error",
...(isESLint7 ? { "no-loss-of-precision": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-misleading-character-class": "error",
"no-mixed-operators": [
"error",
Expand All @@ -108,14 +114,14 @@ module.exports = {
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-nonoctal-decimal-escape": "error",
...(isESLint7 ? { "no-nonoctal-decimal-escape": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-obj-calls": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-param-reassign": ["error", { props: false }],
"no-process-env": "error",
"no-process-exit": "error",
"no-promise-executor-return": "error",
...(isESLint7 ? { "no-promise-executor-return": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-prototype-builtins": "error",
"no-redeclare": ["error", { builtinGlobals: true }],
"no-regex-spaces": "error",
Expand Down Expand Up @@ -146,10 +152,10 @@ module.exports = {
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unreachable": "error",
"no-unreachable-loop": "error",
...(isESLint7 ? { "no-unreachable-loop": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-unsafe-finally": "error",
"no-unsafe-negation": ["error", { enforceForOrderingRelations: true }],
"no-unsafe-optional-chaining": "error",
...(isESLint7 ? { "no-unsafe-optional-chaining": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-unused-vars": [
Expand All @@ -163,7 +169,7 @@ module.exports = {
},
],
"no-use-before-define": ["error", "nofunc"],
"no-useless-backreference": "error",
...(isESLint7 ? { "no-useless-backreference": "off" } : {}), // TODO: enable once we drop ESLint v6 support
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-concat": "error",
Expand Down

0 comments on commit 8ed466a

Please sign in to comment.