Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to ESLint 9, flatconfig and Node.js 18 (#173) #175

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 20
- 18
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
8 changes: 8 additions & 0 deletions conf/eslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = [
{
rules: {
'no-alert': 1,
'camelcase': 2
}
}
];
6 changes: 0 additions & 6 deletions conf/eslint.json

This file was deleted.

16 changes: 9 additions & 7 deletions conf/rules/no-alert.js
Original file line number Diff line number Diff line change
@@ -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.');
}
}
}
};
};
}
};
9 changes: 7 additions & 2 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
'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']
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=12"
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"scripts": {
"test": "grunt"
Expand All @@ -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"
},
Expand Down
10 changes: 7 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ 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']
}
Expand All @@ -46,7 +50,7 @@ grunt.initConfig({
grunt.initConfig({
eslint: {
options: {
format: require('eslint-tap')
format: './node_modules/eslint-tap/index.js'
},
target: ['file.js']
}
Expand Down
Loading