Skip to content

Commit 5639937

Browse files
committed
fix: eslint errors
1 parent b525d61 commit 5639937

File tree

3 files changed

+146
-158
lines changed

3 files changed

+146
-158
lines changed

lint-staged.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
'(src|test)/**/*.[tj]s': (filenames) => [
33
`eslint --fix ${filenames.join(' ')}`,
4-
'node --require babel-register-ts test',
4+
'jest',
55
],
66
'(README).md': ["doctoc --title '**Table of Contents**'"],
77
};

test/.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"globals": {
33
"testRule": "readonly",
4+
"testOptions": "readonly"
45
},
56
"rules": {
67
"import/no-extraneous-dependencies": ["error", {

test/auto-fix-func.js

+144-157
Original file line numberDiff line numberDiff line change
@@ -3,171 +3,158 @@ import autoFixFunc from './helpers/auto-fix-func';
33
import autoFixFuncWithThrow from './helpers/auto-fix-func-with-throw';
44

55
// works if autofix is omitted
6-
testRule(
7-
{
8-
ruleName,
9-
10-
config: ['color'],
11-
12-
reject: [
13-
{
14-
code: '.foo { color: #fff; }',
15-
message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
16-
line: 1,
17-
column: 8,
18-
},
19-
{
20-
code: '.foo { color: red; }',
21-
message: `Expected variable or function for "red" of "color" (${ruleName})`,
22-
line: 1,
23-
column: 8,
24-
},
25-
],
26-
}
27-
);
6+
testRule({
7+
ruleName,
8+
9+
config: ['color'],
10+
11+
reject: [
12+
{
13+
code: '.foo { color: #fff; }',
14+
message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
15+
line: 1,
16+
column: 8,
17+
},
18+
{
19+
code: '.foo { color: red; }',
20+
message: `Expected variable or function for "red" of "color" (${ruleName})`,
21+
line: 1,
22+
column: 8,
23+
},
24+
],
25+
});
2826

2927
// autofix by function property
30-
testRule(
31-
{
32-
skip: true,
33-
ruleName,
34-
fix: true,
35-
36-
config: [
37-
['color', 'font-size', 'display'],
38-
{
39-
autoFixFunc: autoFixFuncWithThrow,
40-
},
41-
],
42-
43-
reject: [
44-
{
45-
code: '.foo { color: #fff; }',
46-
fixed: '.foo { color: $color-white; }',
47-
message: `Expected variable or function for "#fff" of "color" (scale-unlimited/declaration-strict-value)`,
48-
},
49-
{
50-
code: '.foo { color: red; }',
51-
fixed: '.foo { color: $color-red; }',
52-
message: `Expected variable or function for "red" of "color" (scale-unlimited/declaration-strict-value)`,
53-
},
54-
{
55-
code: '.foo { font-size: 16px; }',
56-
unfixable: true,
57-
// message: `"font-size" is not a color property (${ruleName})`,
58-
message: `Expected variable or function for "16px" of "font-size" (${ruleName})`,
59-
line: 1,
60-
column: 8,
61-
},
62-
{
63-
code: '.foo { color: blue; }',
64-
unfixable: true,
65-
// message: `Can't fix color "blue" (${ruleName})`,
66-
message: `Expected variable or function for "blue" of "color" (scale-unlimited/declaration-strict-value)`,
67-
line: 1,
68-
column: 8,
69-
},
70-
{
71-
code: '.foo { display: block; }',
72-
unfixable: true,
73-
// message: `Property "display" with value "block" can't be autofixed (${ruleName})`,
74-
message: `Expected variable or function for "block" of "display" (scale-unlimited/declaration-strict-value)`,
75-
line: 1,
76-
column: 8,
77-
},
78-
],
79-
}
80-
);
28+
testRule({
29+
skip: true,
30+
ruleName,
31+
fix: true,
32+
33+
config: [
34+
['color', 'font-size', 'display'],
35+
{
36+
autoFixFunc: autoFixFuncWithThrow,
37+
},
38+
],
39+
40+
reject: [
41+
{
42+
code: '.foo { color: #fff; }',
43+
fixed: '.foo { color: $color-white; }',
44+
message: `Expected variable or function for "#fff" of "color" (scale-unlimited/declaration-strict-value)`,
45+
},
46+
{
47+
code: '.foo { color: red; }',
48+
fixed: '.foo { color: $color-red; }',
49+
message: `Expected variable or function for "red" of "color" (scale-unlimited/declaration-strict-value)`,
50+
},
51+
{
52+
code: '.foo { font-size: 16px; }',
53+
unfixable: true,
54+
// message: `"font-size" is not a color property (${ruleName})`,
55+
message: `Expected variable or function for "16px" of "font-size" (${ruleName})`,
56+
line: 1,
57+
column: 8,
58+
},
59+
{
60+
code: '.foo { color: blue; }',
61+
unfixable: true,
62+
// message: `Can't fix color "blue" (${ruleName})`,
63+
message: `Expected variable or function for "blue" of "color" (scale-unlimited/declaration-strict-value)`,
64+
line: 1,
65+
column: 8,
66+
},
67+
{
68+
code: '.foo { display: block; }',
69+
unfixable: true,
70+
// message: `Property "display" with value "block" can't be autofixed (${ruleName})`,
71+
message: `Expected variable or function for "block" of "display" (scale-unlimited/declaration-strict-value)`,
72+
line: 1,
73+
column: 8,
74+
},
75+
],
76+
});
8177

8278
// autofix by function property disabled
83-
testRule(
84-
{
85-
skip: true,
86-
ruleName,
87-
fix: true,
88-
89-
config: [
90-
'color',
91-
{
92-
autoFixFunc,
93-
disableFix: true,
94-
},
95-
],
96-
97-
reject: [
98-
{
99-
code: '.foo { color: #fff; }',
100-
fixed: '.foo { color: $color-white; }',
101-
message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
102-
line: 1,
103-
column: 8,
104-
},
105-
{
106-
code: '.foo { color: red; }',
107-
fixed: '.foo { color: $color-red; }',
108-
message: `Expected variable or function for "red" of "color" (${ruleName})`,
109-
line: 1,
110-
column: 8,
111-
},
112-
],
113-
}
114-
);
79+
testRule({
80+
skip: true,
81+
ruleName,
82+
fix: true,
83+
84+
config: [
85+
'color',
86+
{
87+
autoFixFunc,
88+
disableFix: true,
89+
},
90+
],
91+
92+
reject: [
93+
{
94+
code: '.foo { color: #fff; }',
95+
fixed: '.foo { color: $color-white; }',
96+
message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
97+
line: 1,
98+
column: 8,
99+
},
100+
{
101+
code: '.foo { color: red; }',
102+
fixed: '.foo { color: $color-red; }',
103+
message: `Expected variable or function for "red" of "color" (${ruleName})`,
104+
line: 1,
105+
column: 8,
106+
},
107+
],
108+
});
115109

116110
// autofix by file exporting function
117-
testRule(
118-
{
119-
skip: true,
120-
ruleName,
121-
fix: true,
122-
123-
config: [
124-
'color',
125-
{
126-
autoFixFunc: './test/helpers/auto-fix-func.js',
127-
},
128-
],
129-
130-
accept: [
131-
{ code: '.foo { color: #fff; }' },
132-
{ code: '.foo { color: red; }' },
133-
],
134-
}
135-
);
111+
testRule({
112+
skip: true,
113+
ruleName,
114+
fix: true,
115+
116+
config: [
117+
'color',
118+
{
119+
autoFixFunc: './test/helpers/auto-fix-func.js',
120+
},
121+
],
122+
123+
accept: [{ code: '.foo { color: #fff; }' }, { code: '.foo { color: red; }' }],
124+
});
136125

137126
// autofix by file exporting function disabled
138-
testRule(
139-
{
140-
ruleName,
141-
fix: true,
142-
143-
config: [
144-
'color',
145-
{
146-
autoFixFunc: './test/helpers/auto-fix-func.js',
147-
disableFix: true,
148-
},
149-
],
150-
151-
reject: [
152-
{
153-
code: '.foo { color: #fff; }',
154-
// fixed: '.foo { color: $color-white; }',
155-
unfixable: true,
156-
message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
157-
line: 1,
158-
column: 8,
159-
},
160-
{
161-
code: '.foo { color: red; }',
162-
// fixed: '.foo { color: $color-red; }',
163-
unfixable: true,
164-
message: `Expected variable or function for "red" of "color" (${ruleName})`,
165-
line: 1,
166-
column: 8,
167-
},
168-
],
169-
}
170-
);
127+
testRule({
128+
ruleName,
129+
fix: true,
130+
131+
config: [
132+
'color',
133+
{
134+
autoFixFunc: './test/helpers/auto-fix-func.js',
135+
disableFix: true,
136+
},
137+
],
138+
139+
reject: [
140+
{
141+
code: '.foo { color: #fff; }',
142+
// fixed: '.foo { color: $color-white; }',
143+
unfixable: true,
144+
message: `Expected variable or function for "#fff" of "color" (${ruleName})`,
145+
line: 1,
146+
column: 8,
147+
},
148+
{
149+
code: '.foo { color: red; }',
150+
// fixed: '.foo { color: $color-red; }',
151+
unfixable: true,
152+
message: `Expected variable or function for "red" of "color" (${ruleName})`,
153+
line: 1,
154+
column: 8,
155+
},
156+
],
157+
});
171158

172159
testOptions({
173160
skip: true,

0 commit comments

Comments
 (0)