Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (testCase.column !== undefined) {
expect(_.get(warning, 'column')).toBe(testCase.column);
}
if (!schema.fix) {
return;
}
if (!testCase.fixed) {
throw new Error(
'If using { fix: true } in test schema, all reject cases must have { fixed: .. }'
);
}
// Check the fix
return stylelint.lint(Object.assign({ fix: true }, options)).then(output2 => {
const fixedCode = getOutputCss(output2);
expect(fixedCode).toBe(testCase.fixed);
expect(output2.results[0].warnings.length).toBe(0); // Ensure errors are not reported on fixed code
});
});
});
test("Stylelint configuration", function (t) {
stylelint.lint({
code: "a { color: red; top: 0; }",
config,
}).then(function (output) {
const actual = output.results[0].warnings[0].text.trim();
t.equal(actual, "Expected \"top\" to come before \"color\" (order/properties-order)")
t.end()
}).catch(function (err) {
t.notOk(err)
t.end()
})
})
it('fixes padding', () => {
return stylelint
.lint({
code: dedent`
.x { padding: 4px 8px 0; }
`,
config: configWithOptions(true, {verbose: true}),
fix: true
})
.then(data => {
expect(data).not.toHaveErrored()
expect(data).toHaveWarningsLength(0)
expect(data.output).toEqual(dedent`
.x { padding: $spacer-1 $spacer-2 0; }
`)
})
})
beforeEach( () => {
result = stylelint.lint({
code: invalidCss,
config,
});
});
beforeEach( () => {
result = stylelint.lint({
code: validCss,
config,
});
});
beforeEach( () => {
result = stylelint.lint({
code: validCss,
config,
});
});
beforeEach( () => {
result = stylelint.lint({
code: invalidCss,
config,
});
});
var files = program.args.pop();
if (!files) {
console.log('You must supply the path of files to lint.');
process.exit();
}
var formatter = program.formatter || 'verbose';
var ignoredFiles = program['ignore-files'];
if (ignoredFiles) {
lintConfig['ignoreFiles'] = ignoredFiles;
}
stylelint.lint({
files: files,
config: program.config || lintConfig,
configBasedir: path.join(__dirname, '../', './src'),
syntax: program.syntax || 'scss',
formatter: formatter
}).then(function(output) {
var outputFormatter = formatters[formatter];
console.log(outputFormatter && outputFormatter(output.results));
if (output.errored) {
process.exit(1);
}
}).catch(function(err) {
console.log(err);
process.exit(1);
});
if (fileInfo.isMediaFile) {
let isStyle = (_.indexOf(['.scss', '.css'], fileInfo.pathParse.ext) > -1);
let isScripts = (_.indexOf(['.js'], fileInfo.pathParse.ext) > -1);
let isScriptsLintUse = (_.indexOf(['.js'], fileInfo.pathParse.ext) > -1) && options.tools.esLint.use;
let isStyleLintUse = (_.indexOf(['.scss', '.css'], fileInfo.pathParse.ext) > -1) && options.tools.stylelint.use;
let isAutoprefixerUse = options.tools.autoprefixer.use;
if (isStyle) {
if (/#=/g.test(fileInfo.content.asset.content) || /\/=/g.test(fileInfo.content.asset.content)) {
isAutoprefixerUse = false;
isStyleLintUse = false;
}
if (isStyleLintUse) {
stylelint.lint({
code: fileInfo.content.asset.content,
config: options.tools.stylelint.config,
formatter: "string",
syntax: "scss"
}).then((data) => {
if (data.errored && data.output) {
eventEmitter.emit('css:error', {
message: data.output
});
if (!options.tools.stylelint.stopOnFail) {
setQueueAsset(conf, state, fileInfo, {},debugMode);
}
}else{
if (isAutoprefixerUse) {
postcss(postCssPlugins).process(fileInfo.content.asset.content, { syntax: syntax }).then(function (result) {
return options => {
const start = new Date();
return stylelint.lint(options).then(data => {
if (data.errored) {
return fail({
start,
end: new Date(),
test: {
path: testPath,
errorMessage: data.output,
},
});
}
return pass({
start,
end: new Date(),
test: { path: testPath },
});