Skip to content

Commit e6cee0f

Browse files
authored
Fix compatibility with ESLint 7 (#1548)
1 parent 0ec2bd7 commit e6cee0f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"xo": "^0.44.0"
8080
},
8181
"peerDependencies": {
82-
"eslint": ">=8.0.0"
82+
"eslint": ">=7.32.0"
8383
},
8484
"ava": {
8585
"files": [

rules/expiring-todo-comments.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
const readPkgUp = require('read-pkg-up');
33
const semver = require('semver');
44
const ci = require('ci-info');
5-
const baseRule = require('eslint/use-at-your-own-risk').builtinRules.get('no-warning-comments');
5+
const getBuiltinRule = require('./utils/get-builtin-rule.js');
6+
7+
const baseRule = getBuiltinRule('no-warning-comments');
68

79
// `unicorn/` prefix is added to avoid conflicts with core rule
810
const MESSAGE_ID_AVOID_MULTIPLE_DATES = 'unicorn/avoidMultipleDates';

rules/utils/get-builtin-rule.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
function getBuiltinRule(id) {
4+
// TODO: Remove this when we drop support for ESLint 7
5+
const eslintVersion = require('eslint/package.json').version;
6+
/* istanbul ignore next */
7+
if (eslintVersion.startsWith('7.')) {
8+
return require(`eslint/lib/rules/${id}`);
9+
}
10+
11+
return require('eslint/use-at-your-own-risk').builtinRules.get(id);
12+
}
13+
14+
module.exports = getBuiltinRule;

0 commit comments

Comments
 (0)