Skip to content

Commit ebced6b

Browse files
author
Devin McIntyre
committed
update to ESLint 9
1 parent a06b80a commit ebced6b

File tree

10 files changed

+124
-9682
lines changed

10 files changed

+124
-9682
lines changed

.eslintrc.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Auto detect text files and perform LF normalization
2-
* text=auto
2+
* text eol=lf

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
npm-debug.log
33
package-lock.json
44
yarn.lock
5+
.idea
6+
eslint-report.html
7+
/test

copy-fixtures.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { promisify } from "node:util";
2+
import chip from "node:child_process";
3+
import fs from "node:fs";
4+
import path from "node:path";
5+
6+
const exec = promisify( chip.exec );
7+
8+
await exec( "npm install --no-save jquery" );
9+
10+
const fixtures = path.join( ".", "test", "fixtures" );
11+
12+
try {
13+
await fs.promises.mkdir( path.join( ".", "test" ) );
14+
await fs.promises.mkdir( fixtures );
15+
} catch ( _ ) {
16+
await fs.promises.rm(
17+
fixtures,
18+
{
19+
recursive: true
20+
}
21+
);
22+
23+
}
24+
25+
await fs.promises.cp(
26+
path.join( ".", "node_modules", "jquery", "src" ),
27+
path.join( fixtures, "src" ),
28+
{
29+
recursive: true
30+
}
31+
);

eslint.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import jquery from "./index.js";
2+
import globals from "globals";
3+
4+
export default [
5+
{
6+
"languageOptions": {
7+
"globals": {
8+
...globals.amd,
9+
...globals.browser
10+
}
11+
}
12+
},
13+
jquery
14+
];

index.js

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
1-
module.exports = {
1+
2+
import stylistic from "@stylistic/eslint-plugin-js";
3+
4+
export default {
5+
plugins: {
6+
"@stylistic/js": stylistic
7+
},
28
rules: {
3-
"no-negated-in-lhs": "error",
9+
"no-unsafe-negation": "error",
410
"no-cond-assign": [ "error", "except-parens" ],
5-
curly: [ "error", "all" ],
6-
"object-curly-spacing": [ "error", "always" ],
7-
"computed-property-spacing": [ "error", "always" ],
8-
"array-bracket-spacing": [ "error", "always" ],
9-
eqeqeq: [ "error", "smart" ],
11+
"curly": [ "error", "all" ],
12+
"@stylistic/js/object-curly-spacing": [ "error", "always" ],
13+
"@stylistic/js/computed-property-spacing": [ "error", "always" ],
14+
"@stylistic/js/array-bracket-spacing": [ "error", "always" ],
15+
"eqeqeq": [ "error", "smart" ],
1016
"no-unused-expressions": "error",
1117
"no-sequences": "error",
1218
"no-nested-ternary": "error",
1319
"no-unreachable": "error",
14-
"wrap-iife": [ "error", "inside" ],
20+
"@stylistic/js/wrap-iife": [ "error", "inside" ],
1521
"no-caller": "error",
16-
quotes: [ "error", "double" ],
22+
"@stylistic/js/quotes": [ "error", "double" ],
1723
"no-undef": "error",
1824
"no-unused-vars": [
1925
"error",
2026
{
2127
args: "all",
22-
argsIgnorePattern: "^_"
28+
argsIgnorePattern: "^_",
29+
caughtErrors: "none"
2330
}
2431
],
25-
"operator-linebreak": [ "error", "after" ],
26-
"comma-style": [ "error", "last" ],
27-
camelcase: [
32+
"@stylistic/js/operator-linebreak": [ "error", "after" ],
33+
"@stylistic/js/comma-style": [ "error", "last" ],
34+
"camelcase": [
2835
"error",
2936
{
3037
properties: "never"
@@ -36,7 +43,7 @@ module.exports = {
3643
allowPattern: "^[a-z]+(_[a-z]+)+$"
3744
}
3845
],
39-
"max-len": [
46+
"@stylistic/js/max-len": [
4047
"error",
4148
{
4249
code: 100,
@@ -45,24 +52,24 @@ module.exports = {
4552
ignoreRegExpLiterals: true
4653
}
4754
],
48-
"no-mixed-spaces-and-tabs": "error",
49-
"no-trailing-spaces": "error",
55+
"@stylistic/js/no-mixed-spaces-and-tabs": "error",
56+
"@stylistic/js/no-trailing-spaces": "error",
5057
"no-irregular-whitespace": "error",
5158
"no-multi-str": "error",
52-
"comma-dangle": [ "error", "never" ],
53-
"comma-spacing": [
59+
"@stylistic/js/comma-dangle": [ "error", "never" ],
60+
"@stylistic/js/comma-spacing": [
5461
"error",
5562
{
5663
before: false,
5764
after: true
5865
}
5966
],
60-
"space-before-blocks": [ "error", "always" ],
61-
"space-in-parens": [ "error", "always" ],
62-
"keyword-spacing": [ 2 ],
63-
"template-curly-spacing": [ "error", "always" ],
64-
semi: [ "error", "always" ],
65-
"semi-spacing": [
67+
"@stylistic/js/space-before-blocks": [ "error", "always" ],
68+
"@stylistic/js/space-in-parens": [ "error", "always" ],
69+
"@stylistic/js/keyword-spacing": [ 2 ],
70+
"@stylistic/js/template-curly-spacing": [ "error", "always" ],
71+
"@stylistic/js/semi": [ "error", "always" ],
72+
"@stylistic/js/semi-spacing": [
6673
"error",
6774
{
6875

@@ -71,35 +78,35 @@ module.exports = {
7178
after: true
7279
}
7380
],
74-
"no-extra-semi": "error",
75-
"space-infix-ops": "error",
76-
"eol-last": "error",
77-
"lines-around-comment": [
81+
"@stylistic/js/no-extra-semi": "error",
82+
"@stylistic/js/space-infix-ops": "error",
83+
"@stylistic/js/eol-last": "error",
84+
"@stylistic/js/lines-around-comment": [
7885
"error",
7986
{
8087
beforeLineComment: true
8188
}
8289
],
83-
"linebreak-style": [ "error", "unix" ],
90+
"@stylistic/js/linebreak-style": [ "error", "unix" ],
8491
"no-with": "error",
85-
"brace-style": "error",
86-
"space-before-function-paren": [ "error", "never" ],
92+
"@stylistic/js/brace-style": "error",
93+
"@stylistic/js/space-before-function-paren": [ "error", "never" ],
8794
"no-loop-func": "error",
88-
"no-spaced-func": "error",
89-
"key-spacing": [
95+
"@stylistic/js/function-call-spacing": [ "error", "never" ],
96+
"@stylistic/js/key-spacing": [
9097
"error",
9198
{
9299
beforeColon: false,
93100
afterColon: true
94101
}
95102
],
96-
"space-unary-ops": [
103+
"@stylistic/js/space-unary-ops": [
97104
"error",
98105
{
99106
words: false,
100107
nonwords: false
101108
}
102109
],
103-
"no-multiple-empty-lines": 2
110+
"@stylistic/js/no-multiple-empty-lines": 2
104111
}
105112
};

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"name": "eslint-config-jquery",
3-
"version": "3.0.2",
3+
"version": "4.0.0",
44
"description": "jQuery eslint config",
55
"main": "index.js",
6+
"type": "module",
67
"scripts": {
7-
"test": "eslint ."
8+
"test": "npm run copy-fixtures && npm run lint",
9+
"lint": "eslint",
10+
"copy-fixtures": "node copy-fixtures.js"
811
},
912
"repository": {
1013
"type": "git",
@@ -25,7 +28,13 @@
2528
],
2629
"author": "Gaidarenko Oleg <markelog@gmail.com>",
2730
"license": "MIT",
31+
"dependencies": {
32+
"@stylistic/eslint-plugin-js": "^2.9.0"
33+
},
34+
"peerDependencies": {
35+
"eslint": ">=9.0.0"
36+
},
2837
"devDependencies": {
29-
"eslint": "^8.5.0"
38+
"eslint": "^9.12.0"
3039
}
3140
}

readme.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66
npm install --save-dev eslint-config-jquery
77
```
88

9-
Configure ESLint with a `.eslintrc` file using the following contents:
10-
```json
11-
{
12-
"extends": "jquery"
13-
}
9+
Version 4.0.0 and above work for ESLint version 9.0.0 and above. Use version 3.0.2 for older ESLint versions.
10+
11+
In your eslint.config file, import it and add it to your flat config array.
12+
13+
```javascript
14+
import jquery from "eslint-config-jquery";
15+
16+
export default [
17+
// ... any other configurations,
18+
jquery,
19+
// ... any other configurations
20+
];
21+
1422
```
1523

1624
## Status
@@ -20,3 +28,11 @@ This config follows the spirit of the jQuery [code style](https://contribute.jqu
2028
## Semver policy
2129

2230
Same approach as in ESLint, see https://github.com/eslint/eslint#user-content-semantic-versioning-policy.
31+
32+
## Testing
33+
34+
To avoid a circular dependency, testing copies JQuery source code into the test directory before running linting for
35+
this project.
36+
37+
Note: JQuery 3.7.1 has an invalid eslint ignore statement that makes the tests fail for this project, but that must be
38+
fixed in JQuery itself.

test/fixtures/.eslintrc.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)