Skip to content

Commit 81834b4

Browse files
Update to ESLint 9, support flat config, and require Node.js 18 (#175)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
1 parent 0704be0 commit 81834b4

File tree

7 files changed

+38
-26
lines changed

7 files changed

+38
-26
lines changed

.github/workflows/main.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 16
14-
- 14
15-
- 12
13+
- 20
14+
- 18
1615
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
1918
with:
2019
node-version: ${{ matrix.node-version }}
2120
- run: npm install

conf/eslint.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = [
2+
{
3+
rules: {
4+
'no-alert': 1,
5+
'camelcase': 2
6+
}
7+
}
8+
];

conf/eslint.json

-6
This file was deleted.

conf/rules/no-alert.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
'use strict';
2-
module.exports = function (context) {
3-
return {
4-
CallExpression(node) {
5-
if (node.callee.name === 'alert') {
6-
context.report(node, 'testing custom rules.');
2+
module.exports = {
3+
create(context) {
4+
return {
5+
CallExpression(node) {
6+
if (node.callee.name === 'alert') {
7+
context.report(node, 'testing custom rules.');
8+
}
79
}
8-
}
9-
};
10+
};
11+
}
1012
};

gruntfile.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
'use strict';
2+
3+
const noAlertRule = require('./conf/rules/no-alert');
4+
25
module.exports = grunt => {
36
grunt.initConfig({
47
eslint: {
58
options: {
6-
overrideConfigFile: 'conf/eslint.json',
7-
rulePaths: ['conf/rules'],
9+
overrideConfigFile: 'conf/eslint.js',
10+
plugins: {
11+
noAlertRule
12+
},
813
quiet: true
914
},
1015
validate: ['test/fixture/{1,2}.js']

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"url": "https://sindresorhus.com"
1212
},
1313
"engines": {
14-
"node": ">=12"
14+
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
1515
},
1616
"scripts": {
1717
"test": "grunt"
@@ -28,10 +28,10 @@
2828
],
2929
"dependencies": {
3030
"chalk": "^4.1.2",
31-
"eslint": "^8.44.0"
31+
"eslint": "^9.0.0"
3232
},
3333
"devDependencies": {
34-
"grunt": "^1.0.1",
34+
"grunt": "^1.6.1",
3535
"grunt-cli": "^1.4.3",
3636
"grunt-shell": "^4.0.0"
3737
},

readme.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ grunt.registerTask('default', ['eslint']);
2929
### Custom config and rules
3030

3131
```js
32+
const noAlertRule = require('./conf/rules/no-alert');
33+
3234
grunt.initConfig({
3335
eslint: {
3436
options: {
35-
overrideConfigFile: 'conf/eslint.json',
36-
rulePaths: ['conf/rules']
37+
overrideConfigFile: 'conf/eslint.js',
38+
plugins: {
39+
noAlertRule
40+
}
3741
},
3842
target: ['file.js']
3943
}
@@ -46,7 +50,7 @@ grunt.initConfig({
4650
grunt.initConfig({
4751
eslint: {
4852
options: {
49-
format: require('eslint-tap')
53+
format: './node_modules/eslint-tap/index.js'
5054
},
5155
target: ['file.js']
5256
}

0 commit comments

Comments
 (0)