Skip to content

Commit c1d616a

Browse files
committed
Merge pull request sasstools#153 from DanPurdy/hotfix/cli-config-master
Hotfix Master - Fix CLI custom config assertion error sasstools#150
2 parents 99a0e51 + a1f7304 commit c1d616a

File tree

5 files changed

+206
-2
lines changed

5 files changed

+206
-2
lines changed

bin/sass-lint.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ var detectPattern = function (pattern) {
1414
formatted;
1515

1616
detects = lint.lintFiles(pattern, configOptions, configPath);
17-
formatted = lint.format(detects);
17+
formatted = lint.format(detects, configOptions, configPath);
1818

1919

2020
if (program.verbose) {
21-
lint.outputResults(formatted);
21+
lint.outputResults(formatted, configOptions, configPath);
2222
}
2323

2424

tests/cli.js

+85
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,89 @@ describe('cli', function () {
3333
});
3434

3535
});
36+
37+
// Test custom config path
38+
39+
it('should return JSON from a custom config', function (done) {
40+
var command = 'sass-lint -c tests/yml/.json-lint.yml tests/sass/cli.scss --verbose';
41+
42+
childProcess.exec(command, function (err, stdout) {
43+
44+
if (err) {
45+
return done(err);
46+
}
47+
else {
48+
try {
49+
JSON.parse(stdout);
50+
return done();
51+
}
52+
catch (e) {
53+
return done(new Error('Not JSON'));
54+
}
55+
}
56+
});
57+
});
58+
59+
// Test 0 errors/warnings when rules set to 0 in config
60+
61+
it('should return no errors/warnings', function (done) {
62+
var command = 'sass-lint -c tests/yml/.json-lint.yml tests/sass/cli.scss --verbose';
63+
64+
childProcess.exec(command, function (err, stdout) {
65+
66+
var result = '';
67+
68+
if (err) {
69+
return done(err);
70+
}
71+
72+
else {
73+
try {
74+
result = JSON.parse(stdout);
75+
}
76+
catch (e) {
77+
return done(new Error('Not JSON'));
78+
}
79+
80+
if (result[0].warningCount === 0 && result[0].errorCount === 0) {
81+
return done();
82+
}
83+
else {
84+
return done(new Error('warnings/errors were returned'));
85+
}
86+
87+
}
88+
});
89+
});
90+
91+
// Test 1 warning when rules set to 0 in config
92+
93+
it('should return a warning', function (done) {
94+
var command = 'sass-lint -c tests/yml/.color-keyword-errors.yml tests/sass/cli.scss --verbose';
95+
96+
childProcess.exec(command, function (err, stdout) {
97+
98+
var result = '';
99+
100+
if (err) {
101+
return done(err);
102+
}
103+
104+
else {
105+
try {
106+
result = JSON.parse(stdout);
107+
}
108+
catch (e) {
109+
return done(new Error('Not JSON'));
110+
}
111+
112+
if (result[0].warningCount === 1 && result[0].errorCount === 0) {
113+
return done();
114+
}
115+
else {
116+
return done(new Error('warnings/errors were expected to be returned but weren\'t'));
117+
}
118+
}
119+
});
120+
});
36121
});

tests/sass/cli.scss

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.cli {
2+
color: red;
3+
}

tests/yml/.color-keyword-errors.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
options:
2+
formatter: json
3+
files:
4+
include: '**/*.s+(a|c)ss'
5+
rules:
6+
# Extends
7+
extends-before-mixins: 0
8+
extends-before-declarations: 0
9+
placeholder-in-extend: 0
10+
11+
# Mixins
12+
mixins-before-declarations: 0
13+
14+
# Line Spacing
15+
one-declaration-per-line: 0
16+
empty-line-between-blocks: 0
17+
single-line-per-selector: 0
18+
19+
# Disallows
20+
no-debug: 0
21+
no-duplicate-properties: 0
22+
no-empty-rulesets: 0
23+
no-extends: 0
24+
no-ids: 0
25+
no-important: 0
26+
no-warn: 0
27+
no-color-keywords: 1
28+
no-invalid-hex: 0
29+
no-css-comments: 0
30+
no-color-literals: 0
31+
no-vendor-prefix: 0
32+
33+
# Style Guide
34+
border-zero: 0
35+
clean-import-paths: 0
36+
empty-args: 0
37+
hex-length: 0
38+
hex-notation: 0
39+
indentation: 0
40+
leading-zero: 0
41+
nesting-depth: 0
42+
property-sort-order: 0
43+
quotes: 0
44+
variable-for-property: 0
45+
zero-unit: 0
46+
47+
# Inner Spacing
48+
space-after-comma: 0
49+
space-before-colon: 0
50+
space-after-colon: 0
51+
space-before-brace: 0
52+
space-before-bang: 0
53+
space-after-bang: 0
54+
space-between-parens: 0
55+
56+
# Final Items
57+
trailing-semicolon: 0
58+
final-newline: 0

tests/yml/.json-lint.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
options:
2+
formatter: json
3+
files:
4+
include: '**/*.s+(a|c)ss'
5+
rules:
6+
# Extends
7+
extends-before-mixins: 0
8+
extends-before-declarations: 0
9+
placeholder-in-extend: 0
10+
11+
# Mixins
12+
mixins-before-declarations: 0
13+
14+
# Line Spacing
15+
one-declaration-per-line: 0
16+
empty-line-between-blocks: 0
17+
single-line-per-selector: 0
18+
19+
# Disallows
20+
no-debug: 0
21+
no-duplicate-properties: 0
22+
no-empty-rulesets: 0
23+
no-extends: 0
24+
no-ids: 0
25+
no-important: 0
26+
no-warn: 0
27+
no-color-keywords: 0
28+
no-invalid-hex: 0
29+
no-css-comments: 0
30+
no-color-literals: 0
31+
no-vendor-prefix: 0
32+
33+
# Style Guide
34+
border-zero: 0
35+
clean-import-paths: 0
36+
empty-args: 0
37+
hex-length: 0
38+
hex-notation: 0
39+
indentation: 0
40+
leading-zero: 0
41+
nesting-depth: 0
42+
property-sort-order: 0
43+
quotes: 0
44+
variable-for-property: 0
45+
zero-unit: 0
46+
47+
# Inner Spacing
48+
space-after-comma: 0
49+
space-before-colon: 0
50+
space-after-colon: 0
51+
space-before-brace: 0
52+
space-before-bang: 0
53+
space-after-bang: 0
54+
space-between-parens: 0
55+
56+
# Final Items
57+
trailing-semicolon: 0
58+
final-newline: 0

0 commit comments

Comments
 (0)