Skip to content

Commit 8ed466a

Browse files
committed
fix: don't add rules if they're not available
1 parent 9225766 commit 8ed466a

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

.github/workflows/CI.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ on:
1515

1616
jobs:
1717
lint:
18-
name: ⬣ Lint
18+
name: ⬣ Lint (ESLint@${{ matrix.eslint }})
19+
strategy:
20+
matrix:
21+
eslint: [6, 7]
1922
runs-on: ubuntu-latest
2023
steps:
2124
- name: 🛑 Cancel Previous Runs
@@ -32,6 +35,9 @@ jobs:
3235
- name: 📥 Install dependencies
3336
run: npm install
3437

38+
- name: 📥 Install ESLint v${{ matrix.eslint }}
39+
run: npm install --save-dev eslint@${{ matrix.eslint }}
40+
3541
- name: ▶️ Run lint script
3642
run: npm run lint
3743

lib/configs/_base.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
*/
55
"use strict"
66

7+
const { ESLint, version: ESLintVersion } = require("eslint")
8+
9+
const version = ESLint.version || ESLintVersion
10+
const isESLint7 = version.startsWith("7")
11+
12+
/** @type {import('eslint').Linter.Config} */
713
module.exports = {
814
root: true,
915
plugins: ["@eslint-community/mysticatea"],
@@ -27,7 +33,7 @@ module.exports = {
2733
"consistent-return": "error",
2834
curly: "error",
2935
"default-case": "error",
30-
"default-case-last": "error",
36+
...(isESLint7 ? { "default-case-last": "off" } : {}), // TODO: enable once we drop ESLint v6 support
3137
"default-param-last": "error",
3238
"dot-notation": "error",
3339
eqeqeq: ["error", "always", { null: "ignore" }],
@@ -93,7 +99,7 @@ module.exports = {
9399
"no-lone-blocks": "error",
94100
"no-lonely-if": "error",
95101
"no-loop-func": "error",
96-
"no-loss-of-precision": "error",
102+
...(isESLint7 ? { "no-loss-of-precision": "off" } : {}), // TODO: enable once we drop ESLint v6 support
97103
"no-misleading-character-class": "error",
98104
"no-mixed-operators": [
99105
"error",
@@ -108,14 +114,14 @@ module.exports = {
108114
"no-new-object": "error",
109115
"no-new-require": "error",
110116
"no-new-wrappers": "error",
111-
"no-nonoctal-decimal-escape": "error",
117+
...(isESLint7 ? { "no-nonoctal-decimal-escape": "off" } : {}), // TODO: enable once we drop ESLint v6 support
112118
"no-obj-calls": "error",
113119
"no-octal": "error",
114120
"no-octal-escape": "error",
115121
"no-param-reassign": ["error", { props: false }],
116122
"no-process-env": "error",
117123
"no-process-exit": "error",
118-
"no-promise-executor-return": "error",
124+
...(isESLint7 ? { "no-promise-executor-return": "off" } : {}), // TODO: enable once we drop ESLint v6 support
119125
"no-prototype-builtins": "error",
120126
"no-redeclare": ["error", { builtinGlobals: true }],
121127
"no-regex-spaces": "error",
@@ -146,10 +152,10 @@ module.exports = {
146152
"no-unmodified-loop-condition": "error",
147153
"no-unneeded-ternary": "error",
148154
"no-unreachable": "error",
149-
"no-unreachable-loop": "error",
155+
...(isESLint7 ? { "no-unreachable-loop": "off" } : {}), // TODO: enable once we drop ESLint v6 support
150156
"no-unsafe-finally": "error",
151157
"no-unsafe-negation": ["error", { enforceForOrderingRelations: true }],
152-
"no-unsafe-optional-chaining": "error",
158+
...(isESLint7 ? { "no-unsafe-optional-chaining": "off" } : {}), // TODO: enable once we drop ESLint v6 support
153159
"no-unused-expressions": "error",
154160
"no-unused-labels": "error",
155161
"no-unused-vars": [
@@ -163,7 +169,7 @@ module.exports = {
163169
},
164170
],
165171
"no-use-before-define": ["error", "nofunc"],
166-
"no-useless-backreference": "error",
172+
...(isESLint7 ? { "no-useless-backreference": "off" } : {}), // TODO: enable once we drop ESLint v6 support
167173
"no-useless-call": "error",
168174
"no-useless-catch": "error",
169175
"no-useless-concat": "error",

0 commit comments

Comments
 (0)