8000 Build: Update ESLint, switch to the flat config · jquery/jquery-color@a7935ab · GitHub
[go: up one dir, main page]

Skip to content

Commit a7935ab

Browse files
committed
Build: Update ESLint, switch to the flat config
1 parent fbacd75 commit a7935ab

File tree

10 files changed

+306
-241
lines changed

10 files changed

+306
-241
lines changed

.eslintignore

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

.eslintrc.json

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

Gruntfile.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module.exports = grunt => {
2-
31
"use strict";
42

3+
module.exports = grunt => {
4+
55
const max 10000 = [
66
"dist/jquery.color.js",
77
"dist/jquery.color.svg-names.js"
@@ -99,14 +99,12 @@ grunt.initConfig( {
9999
quiet: true
100100
},
101101

102-
source: {
103-
src: [ "jquery.color.js", "jquery.color.svg-names.js" ]
104-
},
105-
grunt: {
106-
src: "Gruntfile.js"
107-
},
108-
test: {
109-
src: "test/unit/**"
102+
all: {
103+
src: [
104+
"*.*js",
105+
"build/**/*.*js",
106+
"test/**/*.*js"
107+
]
110108
}
111109
},
112110

eslint.config.mjs

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import jqueryConfig from "eslint-config-jquery";
2+
import globals from "globals";
3+
4+
export default [
5+
{
6+
7+
// Only global ignores will bypass the parser
8+
// and avoid JS parsing errors
9+
// See https://github.com/eslint/eslint/discussions/17412
10+
ignores: [
11+
"dist",
12+
"external"
13+
]
14+
},
15+
16+
{
17+
files: [
18+
"*.js",
19+
"*.cjs"
20+
],
21+
languageOptions: {
22+
ecmaVersion: 6,
23+
sourceType: "script",
24+
globals: {
25+
...globals.node
26+
}
27+
},
28+
rules: {
29+
...jqueryConfig.rules,
30+
strict: [ "error", "global" ],
31+
32+
// Increase max-len to 150 for now, there are too many violations and the rule
33+
// is not auto-fixable.
34+
// "max-len": [
35+
// "error",
36+
// {
37+
// "code": 150,
38+
// "ignoreComments": true
39+
// }
40+
// ]
41+
}
42+
},
43+
44+
{
45+
files: [
46+
"build",
47+
"test/runner/**/*"
48+
],
49+
ignores: [
50+
"test/runner/listeners.js"
51+
],
52+
languageOptions: {
53+
ecmaVersion: 2022,
54+
sourceType: "module",
55+
globals: {
56+
...globals.node
57+
}
58+
},
59+
rules: {
60+
...jqueryConfig.rules,
61+
strict: [ "error", "global" ],
62+
63+
// Increase max-len to 150 for now, there are too many violations and the rule
64+
// is not auto-fixable.
65+
// "max-len": [
66+
// "error",
67+
// {
68+
// "code": 150,
69+
// "ignoreComments": true
70+
// }
71+
// ]
72+
}
73+
},
74+
75+
{
76+
files: [
77+
"test/runner/listeners.js"
78+
],
79+
languageOptions: {
80+
ecmaVersion: 5,
81+
sourceType: "script",
82+
globals: {
83+
...globals.browser,
84+
QUnit: false,
85+
Symbol: false
86+
}
87+
},
88+
rules: {
89+
...jqueryConfig.rules,
90+
strict: [ "error", "function" ],
91+
92+
}
93+
},
94+
95+
{
96+
files: [
97+
"jquery.color.*",
98+
"test/**/*"
99+
],
100+
ignores: [
101+
"test/runner/**/*"
102+
],
103+
languageOptions: {
104+
ecmaVersion: 5,
105+
sourceType: "script",
106+
globals: {
107+
...globals.browser,
108+
"jQuery": true,
109+
"define": true,
110+
"require": true,
111+
"module": true
112+
}
113+
},
114+
rules: {
115+
...jqueryConfig.rules,
116+
strict: [ "error", "function" ]
117+
}
118+
},
119+
120+
{
121+
files: [
122+
"test/**/*"
123+
],
124+
ignores: [
125+
"test/runner/**/*"
126+
],
127+
languageOptions: {
128+
globals: {
129+
"QUnit": true
130+
}
131+
},
132+
rules: {
133+
strict: [ "error", "global" ],
134+
135+
// Increase max-len to 150 for now, there are too many violations
136+
// and the rule is not auto-fixable.
137+
"max-len": [
138+
"error",
139+
{
140+
"code": 150,
141+
"ignoreComments": true
142+
}
143+
]
144+
}
145+
}
146+
];

jquery.color.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111

1212
( function( root, factory ) {
13+
"use strict";
14+
1315
if ( typeof define === "function" && define.amd ) {
1416

1517
// AMD. Register as an anonymous module.
@@ -20,6 +22,7 @@
2022
factory( root.jQuery );
2123
}
2224
} )( this, function( jQuery, undefined ) {
25+
"use strict";
2326

2427
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
2528
"borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
@@ -301,7 +304,10 @@ color.fn = jQuery.extend( color.prototype, {
301304
} );
302305

303306
// everything defined but alpha?
304-
if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
307+
if ( inst[ cache ] && jQuery.inArray(
308+
null,
309+
inst[ cache ].slice( 0, 3 )
310+
) < 0 ) {
305311

306312
// use the default of 1
307313
if ( inst[ cache ][ 3 ] == null ) {
@@ -619,7 +625,9 @@ color.hook = function( hook ) {
619625
set: function( elem, value ) {
620626
var parsed;
621627

622-
if ( value !== "transparent" && ( getType( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
628+
if ( value !== "transparent" &&
629+
( getType( value ) !== "string" ||
630+
( parsed = stringParse( value ) ) ) ) {
623631
value = color( parsed || value );
624632
value = value.toRgbaString();
625633
}

0 commit comments

Comments
 (0)
0