Skip to content

Commit

Permalink
Fix compatibility with ESLint 7 (#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Oct 12, 2021
1 parent 0ec2bd7 commit e6cee0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"xo": "^0.44.0"
},
"peerDependencies": {
"eslint": ">=8.0.0"
"eslint": ">=7.32.0"
},
"ava": {
"files": [
Expand Down
4 changes: 3 additions & 1 deletion rules/expiring-todo-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
const readPkgUp = require('read-pkg-up');
const semver = require('semver');
const ci = require('ci-info');
const baseRule = require('eslint/use-at-your-own-risk').builtinRules.get('no-warning-comments');
const getBuiltinRule = require('./utils/get-builtin-rule.js');

const baseRule = getBuiltinRule('no-warning-comments');

// `unicorn/` prefix is added to avoid conflicts with core rule
const MESSAGE_ID_AVOID_MULTIPLE_DATES = 'unicorn/avoidMultipleDates';
Expand Down
14 changes: 14 additions & 0 deletions rules/utils/get-builtin-rule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

function getBuiltinRule(id) {
// TODO: Remove this when we drop support for ESLint 7
const eslintVersion = require('eslint/package.json').version;
/* istanbul ignore next */
if (eslintVersion.startsWith('7.')) {
return require(`eslint/lib/rules/${id}`);
}

return require('eslint/use-at-your-own-risk').builtinRules.get(id);
}

module.exports = getBuiltinRule;

0 comments on commit e6cee0f

Please sign in to comment.