How to use the stylelint.createLinter function in stylelint

To help you get started, we’ve selected a few stylelint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexilyaev / stylelint-find-rules / src / lib / cli.js View on Github external
.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 => {
github prettier / stylelint-config-prettier / lib / checker.js View on Github external
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.");
        }
github morishitter / stylefmt / lib / params.js View on Github external
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)
  }
}
github learningequality / kolibri / packages / kolibri-tools / lib / lint.js View on Github external
styleLangs.forEach(lang => {
  styleLinters[lang] = stylelint.createLinter({
    config: stylelintConfig,
    syntax: lang,
    fix: true,
    configBasedir: path.resolve(__dirname, '..'),
  });
});
github prettier / stylelint-config-prettier / src / checker.js View on Github external
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);
				}
			});
github dmnsgn / sublime-stylefmt / node_modules / stylefmt / lib / params.js View on Github external
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)
  }
}