Skip to content

Commit 3ae8cf7

Browse files
authored
Upgrade eslint and prettier (#98)
- reformatted code with new default config - upgrade to the new eslint flat config Lockfile 800 -> 500 lines
1 parent d435e61 commit 3ae8cf7

10 files changed

Lines changed: 824 additions & 1088 deletions

File tree

eslint.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
4+
export default [
5+
js.configs.recommended,
6+
{
7+
languageOptions: {
8+
globals: globals.node,
9+
},
10+
},
11+
];

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ function ValueParser(value) {
1010
return new ValueParser(value);
1111
}
1212

13-
ValueParser.prototype.toString = function() {
13+
ValueParser.prototype.toString = function () {
1414
return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
1515
};
1616

17-
ValueParser.prototype.walk = function(cb, bubble) {
17+
ValueParser.prototype.walk = function (cb, bubble) {
1818
walk(this.nodes, cb, bubble);
1919
return this;
2020
};

lib/parse.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var uUpper = "U".charCodeAt(0);
1212
var plus = "+".charCodeAt(0);
1313
var isUnicodeRange = /^[a-f0-9?-]+$/i;
1414

15-
module.exports = function(input) {
15+
module.exports = function (input) {
1616
var tokens = [];
1717
var value = input;
1818

@@ -65,7 +65,7 @@ module.exports = function(input) {
6565
type: "space",
6666
sourceIndex: pos,
6767
sourceEndIndex: next,
68-
value: token
68+
value: token,
6969
});
7070
}
7171

@@ -78,7 +78,7 @@ module.exports = function(input) {
7878
token = {
7979
type: "string",
8080
sourceIndex: pos,
81-
quote: quote
81+
quote: quote,
8282
};
8383
do {
8484
escape = false;
@@ -108,7 +108,7 @@ module.exports = function(input) {
108108
token = {
109109
type: "comment",
110110
sourceIndex: pos,
111-
sourceEndIndex: next + 2
111+
sourceEndIndex: next + 2,
112112
};
113113

114114
if (next === -1) {
@@ -135,7 +135,7 @@ module.exports = function(input) {
135135
type: "word",
136136
sourceIndex: pos - before.length,
137137
sourceEndIndex: pos + token.length,
138-
value: token
138+
value: token,
139139
});
140140
pos += 1;
141141
code = value.charCodeAt(pos);
@@ -150,7 +150,7 @@ module.exports = function(input) {
150150
sourceEndIndex: pos + token.length,
151151
value: token,
152152
before: before,
153-
after: ""
153+
after: "",
154154
});
155155
before = "";
156156

@@ -170,7 +170,7 @@ module.exports = function(input) {
170170
type: "function",
171171
sourceIndex: pos - name.length,
172172
value: name,
173-
before: value.slice(parenthesesOpenPos + 1, next)
173+
before: value.slice(parenthesesOpenPos + 1, next),
174174
};
175175
pos = next;
176176

@@ -204,8 +204,8 @@ module.exports = function(input) {
204204
type: "word",
205205
sourceIndex: pos,
206206
sourceEndIndex: whitespacePos + 1,
207-
value: value.slice(pos, whitespacePos + 1)
208-
}
207+
value: value.slice(pos, whitespacePos + 1),
208+
},
209209
];
210210
} else {
211211
token.nodes = [];
@@ -216,7 +216,7 @@ module.exports = function(input) {
216216
type: "space",
217217
sourceIndex: whitespacePos + 1,
218218
sourceEndIndex: next,
219-
value: value.slice(whitespacePos + 1, next)
219+
value: value.slice(whitespacePos + 1, next),
220220
});
221221
} else {
222222
token.after = value.slice(whitespacePos + 1, next);
@@ -297,14 +297,14 @@ module.exports = function(input) {
297297
type: "unicode-range",
298298
sourceIndex: pos,
299299
sourceEndIndex: next,
300-
value: token
300+
value: token,
301301
});
302302
} else {
303303
tokens.push({
304304
type: "word",
305305
sourceIndex: pos,
306306
sourceEndIndex: next,
307-
value: token
307+
value: token,
308308
});
309309
}
310310

lib/unit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function likeNumber(value) {
4545

4646
// Consume a number
4747
// https://www.w3.org/TR/css-syntax-3/#consume-number
48-
module.exports = function(value) {
48+
module.exports = function (value) {
4949
var pos = 0;
5050
var length = value.length;
5151
var code;
@@ -115,6 +115,6 @@ module.exports = function(value) {
115115

116116
return {
117117
number: value.slice(0, pos),
118-
unit: value.slice(pos)
118+
unit: value.slice(pos),
119119
};
120120
};

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,14 @@
2626
"lib"
2727
],
2828
"scripts": {
29-
"format": "prettier --write \"**/*.{js,ts}\"",
29+
"format": "prettier --write \"**/*.{js,ts,mjs}\"",
3030
"lint": "eslint .",
3131
"test": "node --test"
3232
},
33-
"eslintConfig": {
34-
"env": {
35-
"es6": true,
36-
"node": true
37-
},
38-
"extends": "eslint:recommended"
39-
},
4033
"devDependencies": {
41-
"eslint": "^5.16.0",
42-
"prettier": "^1.17.1"
34+
"@eslint/js": "^10.0.1",
35+
"eslint": "^10.4.1",
36+
"globals": "^17.6.0",
37+
"prettier": "^3.8.3"
4338
}
4439
}

0 commit comments

Comments
 (0)