diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3b8aa864..4d6b3da6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,9 +10,8 @@ jobs: fail-fast: false matrix: node-version: - - 16 - - 14 - - 12 + - 20 + - 18 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 diff --git a/conf/eslint.js b/conf/eslint.js new file mode 100644 index 00000000..7a1f2c29 --- /dev/null +++ b/conf/eslint.js @@ -0,0 +1,8 @@ +module.exports = [ + { + rules: { + 'no-alert': 1, + 'camelcase': 2 + } + } +]; diff --git a/conf/eslint.json b/conf/eslint.json deleted file mode 100644 index b1ccfef6..00000000 --- a/conf/eslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "rules": { - "no-alert": 1, - "camelcase": 2 - } -} diff --git a/conf/rules/no-alert.js b/conf/rules/no-alert.js index 930d0a29..c126c278 100644 --- a/conf/rules/no-alert.js +++ b/conf/rules/no-alert.js @@ -1,10 +1,12 @@ 'use strict'; -module.exports = function (context) { - return { - CallExpression(node) { - if (node.callee.name === 'alert') { - context.report(node, 'testing custom rules.'); +module.exports = { + create(context) { + return { + CallExpression(node) { + if (node.callee.name === 'alert') { + context.report(node, 'testing custom rules.'); + } } - } - }; + }; + } }; diff --git a/gruntfile.js b/gruntfile.js index 92f22233..096191a8 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -1,10 +1,13 @@ 'use strict'; + +const noAlertRule = require('./conf/rules/no-alert'); + module.exports = grunt => { grunt.initConfig({ eslint: { options: { - overrideConfigFile: 'conf/eslint.json', - rulePaths: ['conf/rules'], + overrideConfigFile: 'conf/eslint.js', + plugins: { noAlertRule }, quiet: true }, validate: ['test/fixture/{1,2}.js'] diff --git a/package.json b/package.json index 9c5895ba..6aa49867 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "https://sindresorhus.com" }, "engines": { - "node": ">=12" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "scripts": { "test": "grunt" @@ -28,10 +28,10 @@ ], "dependencies": { "chalk": "^4.1.2", - "eslint": "^8.44.0" + "eslint": "^9.0.0" }, "devDependencies": { - "grunt": "^1.0.1", + "grunt": "^1.6.1", "grunt-cli": "^1.4.3", "grunt-shell": "^4.0.0" }, diff --git a/readme.md b/readme.md index f852f349..467ea92c 100644 --- a/readme.md +++ b/readme.md @@ -29,11 +29,13 @@ grunt.registerTask('default', ['eslint']); ### Custom config and rules ```js +const noAlertRule = require('./conf/rules/no-alert'); + grunt.initConfig({ eslint: { options: { - overrideConfigFile: 'conf/eslint.json', - rulePaths: ['conf/rules'] + overrideConfigFile: 'conf/eslint.js', + plugins: { noAlertRule } }, target: ['file.js'] } @@ -46,7 +48,7 @@ grunt.initConfig({ grunt.initConfig({ eslint: { options: { - format: require('eslint-tap') + format: './node_modules/eslint-tap/index.js' }, target: ['file.js'] }