Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Commit d1a766f

Browse files
committed
Fix and disable ESLint errors
1 parent 6b5d700 commit d1a766f

6 files changed

+28
-13
lines changed

camel-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function camelCase(str) {
44
return str.replace(/[\w-]+/g, (s) => {
55
return /^-?[a-z]+(?:-[a-z]+)+$/.test(s)
66
? s
7-
.replace(/^-(ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '$1')
7+
.replace(/^-(ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '$1') // eslint-disable-line regexp/no-super-linear-backtracking -- TODO: fix
88
.replace(/-\w/g, (uncasedStr) => uncasedStr[1].toUpperCase())
99
: s;
1010
});

object-parser.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class objectParser {
128128
.slice(parent.nodes[i - 1].raws.node.end, child.raws.node.start)
129129
.replace(/^\s*,+/, '');
130130
} else if (node) {
131-
child.raws.before = source.slice(node.start, child.raws.node.start).replace(/^\s*{+/, '');
131+
child.raws.before = source.slice(node.start, child.raws.node.start).replace(/^\s*\{+/, '');
132132
}
133133
});
134134

@@ -143,10 +143,10 @@ class objectParser {
143143
return '';
144144
});
145145
} else {
146-
after = source.slice(node.start, node.end).replace(/^\s*{/, '');
146+
after = source.slice(node.start, node.end).replace(/^\s*\{/, '');
147147
}
148148

149-
parent.raws.after = after.replace(/}+\s*$/, '');
149+
parent.raws.after = after.replace(/\}+\s*$/, '');
150150
parent.raws.semicolon = semicolon || false;
151151
}
152152
}
@@ -217,10 +217,11 @@ class objectParser {
217217
if (node.value.type === 'ObjectExpression') {
218218
let rule;
219219

220+
// eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking -- TODO: fix
220221
if (/^@(\S+)(\s*)(.*)$/.test(key.value)) {
221-
const name = RegExp.$1;
222-
const afterName = RegExp.$2;
223-
const params = RegExp.$3;
222+
const name = RegExp.$1; // eslint-disable-line regexp/no-legacy-features -- TODO: fix
223+
const afterName = RegExp.$2; // eslint-disable-line regexp/no-legacy-features -- TODO: fix
224+
const params = RegExp.$3; // eslint-disable-line regexp/no-legacy-features -- TODO: fix
224225
const atRule = postcss.atRule({
225226
name: unCamelCase(name),
226227
raws: {
@@ -325,6 +326,7 @@ class objectParser {
325326
return this.comment(node, parent.parent);
326327
}
327328

329+
// eslint-disable-next-line regexp/no-super-linear-backtracking -- TODO: fix
328330
const text = node.value.match(/^(\s*)((?:\S[\s\S]*?)?)(\s*)$/);
329331
const comment = postcss.comment({
330332
text: text[2],

object-stringifier.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class ObjectStringifier extends Stringifier {
9696
!/:/.test(value)
9797
) {
9898
value = `:${value}`;
99-
} else if (own === 'before' && /^(decl|rule)$/.test(node.type)) {
99+
} else if (own === 'before' && /^(?:decl|rule)$/.test(node.type)) {
100100
value = value.replace(/\S+$/, '');
101101
}
102102

@@ -119,11 +119,12 @@ class ObjectStringifier extends Stringifier {
119119
return value;
120120
}
121121

122-
if (/^(prop|selector)$/i.test(prop)) {
122+
if (/^(?:prop|selector)$/i.test(prop)) {
123123
value = camelCase(value);
124124

125+
// eslint-disable-next-line regexp/no-unused-capturing-group -- TODO: fix
125126
if (node.raws.before && /(\S+)$/.test(node.raws.before)) {
126-
value = RegExp.$1 + value;
127+
value = RegExp.$1 + value; // eslint-disable-line regexp/no-legacy-features -- TODO: fix
127128
} else if (value && !/\W/.test(value)) {
128129
return value;
129130
}

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@
5151
"eslintConfig": {
5252
"extends": [
5353
"stylelint"
54-
]
54+
],
55+
"globals": {
56+
"__dirname": true,
57+
"module": true,
58+
"require": true
59+
},
60+
"reportUnusedDisableDirectives": true,
61+
"root": true
5562
},
5663
"remarkConfig": {
5764
"plugins": [
@@ -102,6 +109,9 @@
102109
"postcss": ">=7.0.0",
103110
"postcss-syntax": ">=0.36.2"
104111
},
112+
"engines": {
113+
"node": ">=12.0.0"
114+
},
105115
"publishConfig": {
106116
"access": "public"
107117
}

template-parser-helper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
const Literal = require('./literal');
44
const postcssParse = require('postcss/lib/parse');
5+
6+
// eslint-disable-next-line regexp/no-useless-non-capturing-group, regexp/no-useless-flag -- TODO: fix
57
const reNewLine = /(?:\r?\n|\r)/gm;
68
const isLiteral = (token) => token[0] === 'word' && /^\$\{[\s\S]*\}$/.test(token[1]);
79

@@ -72,7 +74,7 @@ function freeSemicolon(token) {
7274
const nodes = this.current.nodes;
7375
const prev = nodes && nodes[nodes.length - 1];
7476

75-
if (prev && /^(rule|literal)$/.test(prev.type) && !prev.raws.ownSemicolon) {
77+
if (prev && /^(?:rule|literal)$/.test(prev.type) && !prev.raws.ownSemicolon) {
7678
prev.raws.ownSemicolon = this.spaces;
7779
this.spaces = '';
7880
}

un-camel-case.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function unCamelCase(str) {
55
return /^[A-Z]?[a-z]*(?:[A-Z][a-z]*)+$/.test(s)
66
? s
77
.replace(/[A-Z]/g, (casedStr) => `-${casedStr.toLowerCase()}`)
8-
.replace(/^(o|ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '-$1')
8+
.replace(/^(o|ms|moz|khtml|epub|(\w+-?)*webkit)(?=-)/i, '-$1') // eslint-disable-line regexp/no-super-linear-backtracking -- TODO: fix
99
: s;
1010
});
1111
}

0 commit comments

Comments
 (0)