olegskl on 8.0.0
olegskl on master
chore(package): bump version to… (compare)
olegskl on master
Fix reporting for ignored files Add node > 6, node <= 10 to tra… Enforce stylelint@^9.6.0 (compare)
hey guys, i have one problem when using gulp-stylelint
It gave me a error message below:
Error in plugin 'gulp-stylelint'
Message:
No configuration found
Details:
code: 78
my gulp task is like this:
gulp.task('lint-css', function() {
var stylelintConfig = {
'plugins': [
'stylelint-statement-max-nesting-depth'
],
'rules': {
'selector-pseudo-element-colon-notation': 'single',
'statement-max-nesting-depth': [2, { countAtRules: true }],
}
};
return gulp.src(src + css + cofiles)
.pipe($.stylelint(stylelintConfig));
});
config
property that points to the actual config.
.pipe($.stylelint({config: stylelintConfig}));
sorry, i have another problem now =(
This is my stylelintConfig
var stylelintConfig = {
"rules": {
"block-no-empty": null,
"color-no-invalid-hex": true,
"comment-empty-line-before": [ "always", {
"ignore": ["stylelint-commands", "between-comments"],
} ],
"declaration-colon-space-after": "always-single-line",
"indentation": 2,
"rule-nested-empty-line-before": [ "always-multi-line", {
"except": ["first-nested"],
"ignore": ["after-comment"],
} ],
"unit-whitelist": ["em", "rem", "%", "s", "deg"]
}
};
This is my nav.css file
nav {
ul {
margin: 0;
padding: 0;
}
}
error message is:
src/css/layout/nav.css
2:3 ‼ Expected indentation of 0 spaces (indentation) [stylelint]
What happen? Please help me~
const gulp = require('gulp');
const stylelint = require('gulp-stylelint');
gulp.task('lint', function () {
const stylelintConfig = {
"rules": {
"block-no-empty": null,
"color-no-invalid-hex": true,
"comment-empty-line-before": [ "always", {
"ignore": ["stylelint-commands", "between-comments"],
} ],
"declaration-colon-space-after": "always-single-line",
"indentation": 2,
"rule-nested-empty-line-before": [ "always-multi-line", {
"except": ["first-nested"],
"ignore": ["after-comment"],
} ],
"unit-whitelist": ["em", "rem", "%", "s", "deg"]
}
};
gulp.src('*.css')
.pipe(stylelint({
config: stylelintConfig,
reporters: [
{formatter: 'string', console: true}
],
}));
});
gulp lint
you'll get:
foo.css
3:4 ✖ Expected indentation of 4 spaces indentation
4:4 ✖ Expected indentation of 4 spaces indentation
block-no-empty
rule takes null
as value.
pre-push
git hook which runs your lint command. If lint command fails, it will abort the push.
const gulpStylelint = require('gulp-stylelint');
const { src, dest, watch, lastRun } = require('gulp');
function cssLint() {
return src('./src/css/*.css', {since: lastRun(cssLint)})
.pipe(gulpStylelint({fix: true, reporters: [{formatter: 'string', console: true}]}))
.pipe(dest('./src/css/'));
}
function watcher() {
watch('./src/css/*.css', cssLint);
}
exports.cssLint = cssLint;
exports.watch = watcher;