Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(() => {
// If `extends` is defined, use stylelint's extends resolver
if (!_.isEmpty(userConfig.extends)) {
// We need this to fetch and merge all `extends` from the provided config
// This will also merge the `rules` on top of the `extends` rules
const linter = stylelint.createLinter();
// stylelint used cosmiconfig v4 at version 9, bumped to v5 somewhere 9.x
// So we pass both arguments to `load`, works in both versions
return linter._extendExplorer.load(configPath, configPath);
}
})
.then(extendedConfig => {
exports.check = function () {
const stylelintConfig = stylelint.createLinter().getConfigForFile();
const conflictRules = [];
stylelintConfig.then((config) => {
Object.keys(stylelintConfigPrettier.rules).forEach(function (conflictRuleName) {
if (config.config.rules.hasOwnProperty(conflictRuleName)) {
if (config.config.rules[conflictRuleName] !== null) {
if (config.config.rules[conflictRuleName][0] !== stylelintConfigPrettier.rules[conflictRuleName]) {
conflictRules.push(conflictRuleName);
}
}
}
});
if (conflictRules.length !== 0) {
throw new Error("Conflict rule(s) detected in your stylelint configuration :\n" + conflictRules.join("\n"));
}
console.log("No conflict rule detected in your stylelint configuration.");
}
function params (options) {
options = options || {}
var tailoredOptions = (options.rules)
? { config: options }
: options
var stylelint = createStylelint(tailoredOptions)
return function (root, result) {
if (result.stylelint && result.stylelint.ignored) {
return Promise.resolve(null)
}
var file = root.source.input.file || options.from
return loadConfig(stylelint, file, options)
}
}
styleLangs.forEach(lang => {
styleLinters[lang] = stylelint.createLinter({
config: stylelintConfig,
syntax: lang,
fix: true,
configBasedir: path.resolve(__dirname, '..'),
});
});
function check(path) {
const resolvedPath = resolve(process.cwd(), path || '');
return stylelint
.createLinter()
.getConfigForFile(resolvedPath)
.then((config) => {
const prettierRules = stylelintConfigPrettier.rules;
const configRules = config.config.rules;
const conflictingRules = [];
Object.keys(prettierRules).forEach((rule) => {
if (
hasOwnProperty.call(configRules, rule) &&
configRules[rule] !== null &&
configRules[rule][0] !== prettierRules[rule]
) {
conflictingRules.push(rule);
}
});
function params (options) {
options = options || {}
var tailoredOptions = (options.rules)
? { config: options }
: options
var stylelint = createStylelint(tailoredOptions)
return function (root, result) {
if (result.stylelint && result.stylelint.ignored) {
return Promise.resolve(null)
}
var file = root.source.input.file || options.from
return loadConfig(stylelint, file, options)
}
}