Skip to content

Commit 97bb2e2

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

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-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

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

7+
const { ESLint } = require("eslint")
8+
9+
const isESLint7 = ESLint.version.startsWith("7.")
10+
11+
/** @type {import('eslint').Linter.Config} */
712
module.exports = {
813
root: true,
914
plugins: ["@eslint-community/mysticatea"],
@@ -27,7 +32,7 @@ module.exports = {
2732
"consistent-return": "error",
2833
curly: "error",
2934
"default-case": "error",
30-
"default-case-last": "error",
35+
"default-case-last": isESLint7 ? "error" : "off", // TODO: enable once we drop ESLint v6 support
3136
"default-param-last": "error",
3237
"dot-notation": "error",
3338
eqeqeq: ["error", "always", { null: "ignore" }],
@@ -93,7 +98,7 @@ module.exports = {
9398
"no-lone-blocks": "error",
9499
"no-lonely-if": "error",
95100
"no-loop-func": "error",
96-
"no-loss-of-precision": "error",
101+
"no-loss-of-precision": isESLint7 ? "error" : "off", // TODO: enable once we drop ESLint v6 support
97102
"no-misleading-character-class": "error",
98103
"no-mixed-operators": [
99104
"error",
@@ -108,14 +113,14 @@ module.exports = {
108113
"no-new-object": "error",
109114
"no-new-require": "error",
110115
"no-new-wrappers": "error",
111-
"no-nonoctal-decimal-escape": "error",
116+
"no-nonoctal-decimal-escape": isESLint7 ? "error" : "off", // TODO: enable once we drop ESLint v6 support
112117
"no-obj-calls": "error",
113118
"no-octal": "error",
114119
"no-octal-escape": "error",
115120
"no-param-reassign": ["error", { props: false }],
116121
"no-process-env": "error",
117122
"no-process-exit": "error",
118-
"no-promise-executor-return": "error",
123+
"no-promise-executor-return": isESLint7 ? "error" : "off", // TODO: enable once we drop ESLint v6 support
119124
"no-prototype-builtins": "error",
120125
"no-redeclare": ["error", { builtinGlobals: true }],
121126
"no-regex-spaces": "error",
@@ -146,10 +151,10 @@ module.exports = {
146151
"no-unmodified-loop-condition": "error",
147152
"no-unneeded-ternary": "error",
148153
"no-unreachable": "error",
149-
"no-unreachable-loop": "error",
154+
"no-unreachable-loop": isESLint7 ? "error" : "off", // TODO: enable once we drop ESLint v6 support
150155
"no-unsafe-finally": "error",
151156
"no-unsafe-negation": ["error", { enforceForOrderingRelations: true }],
152-
"no-unsafe-optional-chaining": "error",
157+
"no-unsafe-optional-chaining": isESLint7 ? "error" : "off", // TODO: enable once we drop ESLint v6 support
153158
"no-unused-expressions": "error",
154159
"no-unused-labels": "error",
155160
"no-unused-vars": [
@@ -163,7 +168,7 @@ module.exports = {
163168
},
164169
],
165170
"no-use-before-define": ["error", "nofunc"],
166-
"no-useless-backreference": "error",
171+
"no-useless-backreference": isESLint7 ? "error" : "off", // TODO: enable once we drop ESLint v6 support
167172
"no-useless-call": "error",
168173
"no-useless-catch": "error",
169174
"no-useless-concat": "error",

0 commit comments

Comments
 (0)