-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/tidy-mergeable-selectors
- Loading branch information
Showing
9 changed files
with
194 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# No Color Hex | ||
|
||
Rule `no-color-hex` will disallow the use of hexadecimal colors | ||
|
||
## Examples | ||
|
||
When enabled the following are disallowed. | ||
|
||
```scss | ||
$foo-color: #456; | ||
|
||
.bar { | ||
background: linear-gradient(top, #3ff, #ddd); | ||
} | ||
|
||
.baz { | ||
color: #fff; | ||
} | ||
``` | ||
|
||
When enabled the following are allowed: | ||
|
||
```scss | ||
$foo-color: red; | ||
|
||
.bar { | ||
background: linear-gradient(top, blue, green); | ||
} | ||
|
||
.baz { | ||
color: white; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
var helpers = require('../helpers'); | ||
|
||
module.exports = { | ||
'name': 'no-color-hex', | ||
'defaults': {}, | ||
'detect': function (ast, parser) { | ||
var result = []; | ||
|
||
ast.traverseByType('color', function (value) { | ||
result = helpers.addUnique(result, { | ||
'ruleId': parser.rule.name, | ||
'line': value.start.line, | ||
'column': value.start.column, | ||
'message': 'Hexadecimal colors should not be used', | ||
'severity': parser.severity | ||
}); | ||
}); | ||
return result; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
var lint = require('./_lint'); | ||
|
||
////////////////////////////// | ||
// SCSS syntax tests | ||
////////////////////////////// | ||
describe('no color hex - scss', function () { | ||
var file = lint.file('no-color-hex.scss'); | ||
|
||
it('enforce', function (done) { | ||
lint.test(file, { | ||
'no-color-hex': 1 | ||
}, function (data) { | ||
lint.assert.equal(9, data.warningCount); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
////////////////////////////// | ||
// Sass syntax tests | ||
////////////////////////////// | ||
describe('no color hex - sass', function () { | ||
var file = lint.file('no-color-hex.sass'); | ||
|
||
it('enforce', function (done) { | ||
lint.test(file, { | ||
'no-color-hex': 1 | ||
}, function (data) { | ||
lint.assert.equal(9, data.warningCount); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
$foo-color: #123 | ||
|
||
.foo | ||
background: linear-gradient(top, #cc2, #44d) | ||
color: #fff | ||
|
||
|
||
$bar-color: #112233 | ||
|
||
.bar | ||
background: linear-gradient(top, #cccc22, #4444dd) | ||
color: #ffffff | ||
|
||
.baz | ||
border-color: #123456 | ||
|
||
|
||
// color literals, rgb and hsl values currently don't get returned | ||
// by the AST's color type | ||
$qux-color: red | ||
$rgb-color: rgb(255, 255, 255) | ||
$rgba-color: rgba(0, 0, 0, .1) | ||
$hsl-color: hsl(40, 50%, 50%) | ||
$hsla-color: hsla(40, 50%, 50%, .3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$foo-color: #123; | ||
|
||
.foo { | ||
background: linear-gradient(top, #cc2, #44d); | ||
color: #fff; | ||
} | ||
|
||
$bar-color: #112233; | ||
|
||
.bar { | ||
background: linear-gradient(top, #cccc22, #4444dd); | ||
color: #ffffff; | ||
} | ||
|
||
.baz { | ||
border-color: #123456; | ||
} | ||
|
||
// color literals, rgb and hsl values currently don't get returned | ||
// by the AST's color type | ||
|
||
$qux-color: red; | ||
$rgb-color: rgb(255, 255, 255); | ||
$rgba-color: rgba(0, 0, 0, .1); | ||
$hsl-color: hsl(40, 50%, 50%); | ||
$hsla-color: hsla(40, 50%, 50%, .3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters