forked from sasstools/sass-lint
-
Notifications
You must be signed in to change notification settings - Fork 0
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' of github.com:sasstools/sass-lint into feature…
…/shorthand-values
- Loading branch information
Showing
5 changed files
with
95 additions
and
0 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,21 @@ | ||
# No Trailing Zero | ||
|
||
Rule `no-trailing-zero` will enforce that trailing zeros are not allowed. | ||
|
||
## Examples | ||
|
||
When enabled, the following are disallowed: | ||
|
||
```scss | ||
.foo { | ||
margin: 1.500rem; | ||
} | ||
|
||
.foo { | ||
margin: .500rem; | ||
} | ||
|
||
.foo { | ||
margin: 0.2500rem; | ||
} | ||
``` |
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,30 @@ | ||
'use strict'; | ||
|
||
var helpers = require('../helpers'); | ||
|
||
var trailingZeroRegex = /^(\d+\.|\.)+(\d*?[1-9])0+$/; | ||
|
||
module.exports = { | ||
'name': 'no-trailing-zero', | ||
'defaults': { | ||
'include': false | ||
}, | ||
'detect': function (ast, parser) { | ||
var result = []; | ||
|
||
ast.traverseByType('number', function (num) { | ||
|
||
if (num.content.match(trailingZeroRegex)) { | ||
result = helpers.addUnique(result, { | ||
'ruleId': parser.rule.name, | ||
'line': num.start.line, | ||
'column': num.start.column, | ||
'message': 'Don\'t include trailing zeros on numbers', | ||
'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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
var lint = require('./_lint'); | ||
|
||
var file = lint.file('no-trailing-zero.scss'); | ||
|
||
describe('no trailing zero', function () { | ||
it('enforce', function (done) { | ||
lint.test(file, { | ||
'trailing-zero': 1 | ||
}, function (data) { | ||
lint.assert.equal(3, 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,27 @@ | ||
.foo { | ||
margin: 1.5rem; | ||
} | ||
|
||
.foo { | ||
margin: 1.500rem; | ||
} | ||
|
||
.foo { | ||
margin: .5rem; | ||
} | ||
|
||
.foo { | ||
margin: .500rem; | ||
} | ||
|
||
.foo { | ||
margin: 0.25rem; | ||
} | ||
|
||
.foo { | ||
margin: 0.2500rem; | ||
} | ||
|
||
.foo { | ||
margin: 0; | ||
} |