Skip to content
This repository was archived by the owner on Dec 8, 2017. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ postcss(plugins)
.process(sourceCss, processOpts)
.then(function (result) {
result.messages.forEach(function(i) {
console.log('i', i);
console.log('-- RULE', i);
});
});
27 changes: 24 additions & 3 deletions src/plugins.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var postcss = require('postcss');

function LintError (msg, source, obj) {
function LintError(msg, id, source, obj) {
this.msg = msg;
this.id = id;
this.opts = {
line: source.start.line,
column: source.start.column
Expand Down Expand Up @@ -82,8 +83,28 @@ var ensureSpaceInProperty = postcss.plugin('space-in-property', function (opts)
};
});

module.exports = [ensureNoIndentSelectors,
ensureSpaceInRuleName];
var SPC04_SpaceBeforeBracket = postcss.plugin('SPC04_SpaceBeforeBracket',
function(opts) {
opts = opts || {};

return function(css, result) {
var desired = ' ';
css.walkDecls(function(decl) {
var actual = decl.parent.raws.between;

if (actual === desired) return;
var e = new LintError('Put spaces before { in rule declarations.',
'SPC04', decl.source, decl);
result.warn(e.msg, e.opts);
});
};
});

module.exports = [
//ensureNoIndentSelectors,
//ensureSpaceInRuleName,
SPC04_SpaceBeforeBracket
];
// ensureEachPropertyOwnLine,
// ensureSpaceInProperty,
// ensureNewLineBeforeRuleClosing,
Expand Down
4 changes: 2 additions & 2 deletions test/ugly.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
body {
color: green;
}
.div {
.div{
color:blue;
}
/*
.span {
color: yellow;
}
/*
@mixin fakeMixin {
color: coral;
}
Expand Down