Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
postcssPlugins.pop();
}
// Report messages from other postcss plugins
postcssPlugins.push(
reporter({ clearReportedMessages: true })
);
// Return a single stream containing all the
// after replacement functionality
return pipeline.obj([
gulpPlugins.postcss([
AtImport({
path: [paths.styles.srcDir],
plugins: [
stylelint(),
]
})
]),
gulpPlugins.postcss(postcssPlugins),
gulpPlugins.if(
config.dev.debug.styles,
gulpPlugins.tabify(2, true)
),
gulpPlugins.rename({
suffix: '.min'
}),
server.stream({match: "**/*.css"}),
]);
}
test('Declaration order scss', t => {
t.plan(5)
postcss()
.use(stylelint({ code: invalidScss, config: config }))
.process(invalidScss, { syntax: scssSyntax })
.then(checkResult)
.catch(logError)
function checkResult(result) {
console.log(result)
t.equal(result.warnings().length, 4, 'flags 4 warnings')
t.is(
result.warnings()[0].text,
'Expected declaration to come before rule (order/order)',
'correct warning text',
)
t.is(
result.warnings()[1].text,
'Expected blockless @include to come before declaration (order/order)',
'correct warning text',
test("Single line per property scss", t => {
t.plan(4)
postcss()
.use(stylelint({ code: invalidScss, config: config,}))
.process(invalidScss, { syntax: scssSyntax })
.then(checkResult)
.catch(logError)
function checkResult(result) {
t.equal(result.warnings().length, 3, "flags 3 warning")
t.is(result.warnings()[0].text, "Expected newline after \";\" (declaration-block-semicolon-newline-after)", "correct warning text")
t.is(result.warnings()[1].text, "Expected newline after \";\" (declaration-block-semicolon-newline-after)", "correct warning text")
t.is(result.warnings()[2].text, "Expected no more than 1 declaration (declaration-block-single-line-max-declarations)", "correct warning text")
}
})
test("ID selector scss", t => {
t.plan(2)
postcss()
.use(stylelint({ code: invalidScss, config: config,}))
.process(invalidScss, { syntax: scssSyntax })
.then(checkResult)
.catch(logError)
function checkResult(result) {
t.equal(result.warnings().length, 1, "flags 1 warning")
t.is(result.warnings()[0].text, "Expected \"#id-selector\" to have no more than 0 ID selectors (selector-max-id)", "correct warning text")
}
})
test("URL quotes scss", t => {
t.plan(2)
postcss()
.use(stylelint({ code: invalidScss, config: config,}))
.process(invalidScss, { syntax: scssSyntax })
.then(checkResult)
.catch(logError)
function checkResult(result) {
t.equal(result.warnings().length, 1, "flags 1 warning")
t.is(result.warnings()[0].text, "Expected quotes (function-url-quotes)", "correct warning text")
}
})
test("Qualifying element scss", t => {
t.plan(6)
postcss()
.use(stylelint({ code: invalidScss, config: config,}))
.process(invalidScss, { syntax: scssSyntax })
.then(checkResult)
.catch(logError)
function checkResult(result) {
t.equal(result.warnings().length, 5, "flags 5 warning")
t.is(result.warnings()[0].text, "Expected \"div#thing\" to have no more than 0 ID selectors (selector-max-id)", "correct warning text")
t.is(result.warnings()[1].text, "Unexpected qualifying type selector (selector-no-qualifying-type)", "correct warning text")
t.is(result.warnings()[2].text, "Unexpected qualifying type selector (selector-no-qualifying-type)", "correct warning text")
t.is(result.warnings()[3].text, "Unexpected qualifying type selector (selector-no-qualifying-type)", "correct warning text")
t.is(result.warnings()[4].text, "Unexpected qualifying type selector (selector-no-qualifying-type)", "correct warning text")
}
})
test("Empty line between scss", t => {
t.plan(3)
postcss()
.use(stylelint({ code: invalidScss, config: config,}))
.process(invalidScss, { syntax: scssSyntax })
.then(checkResult)
.catch(logError)
function checkResult(result) {
t.equal(result.warnings().length, 2, "flags 2 warning")
t.is(result.warnings()[0].text, "Expected empty line before rule (rule-empty-line-before)", "correct warning text")
t.is(result.warnings()[1].text, "Expected empty line before rule (rule-empty-line-before)", "correct warning text")
}
})
test.only("Nesting depth scss", t => {
t.plan(6)
postcss()
.use(stylelint({ code: invalidScss, config: config }))
.process(invalidScss, { syntax: scssSyntax })
.then(checkResult)
.catch(logError)
function checkResult(result) {
t.equal(result.warnings().length, 3, "flags 3 warning")
t.is(
result.warnings()[0].text,
"Expected nesting depth to be no more than 1 (max-nesting-depth)",
"correct warning text"
)
t.is(
result.warnings()[1].text,
"Expected nesting depth to be no more than 1 (max-nesting-depth)",
export function stylesAfterReplacementStream() {
const config = getThemeConfig();
const postcssPlugins = [
stylelint(),
postcssPresetEnv({
importFrom: (
configValueDefined('config.dev.styles.importFrom') ?
appendBaseToFilePathArray(config.dev.styles.importFrom, paths.styles.srcDir) :
[]
),
stage: (
configValueDefined('config.dev.styles.stage') ?
config.dev.styles.stage :
3
),
autoprefixer: (
configValueDefined('config.dev.styles.autoprefixer') ?
config.dev.styles.autoprefixer :
{}
),
export default function linter() {
return gulp.src('./src/less/**/*.less')
.pipe($.postcss(
[
stylelint(),
reporter({ clearMessages: true }),
],
{
syntax: less,
},
))
.pipe($.duration('linting styles'));
}