How to use the stylelint 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 wprig / wprig / gulp / editorStyles.js View on Github external
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"}),
	]);
}
github bjankord / stylelint-config-sass-guidelines / __tests__ / declaration-order.js View on Github external
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',
github bjankord / stylelint-config-sass-guidelines / __tests__ / single-line-per-property.js View on Github external
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")
  }
})
github bjankord / stylelint-config-sass-guidelines / __tests__ / id-selector.js View on Github external
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")
  }
})
github bjankord / stylelint-config-sass-guidelines / __tests__ / url-quotes.js View on Github external
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")
  }
})
github bjankord / stylelint-config-sass-guidelines / __tests__ / qualifying-element.js View on Github external
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")
  }
})
github bjankord / stylelint-config-sass-guidelines / __tests__ / empty-line-between-blocks.js View on Github external
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")
  }
})
github bjankord / stylelint-config-sass-guidelines / __tests__ / nesting-depth.js View on Github external
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)",
github wprig / wprig / gulp / styles.js View on Github external
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 :
				{}
			),
github rhinogram / rhinostyle / config / linter.js View on Github external
export default function linter() {
  return gulp.src('./src/less/**/*.less')
    .pipe($.postcss(
      [
        stylelint(),
        reporter({ clearMessages: true }),
      ],
      {
        syntax: less,
      },
    ))
    .pipe($.duration('linting styles'));
}