stylelint-define-config
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

stylelint-define-config

Static Badge npm npm peer dependency version npm GitHub License

Provide a defineConfig function for stylelint.config.js.

Install

npm i -D stylelint-define-config
# or
pnpm add -D stylelint-define-config
# or
yarn add -D stylelint-define-config

Usage

By default only stylelint's rules are supported. To activate auto-suggestions for Rules of specific plugins, you need to install the respective types for that plugin.

Plugins can either support their own types, or they could be supported by the community in the @stylelint-types repository.

stylelint.config.js

// @ts-check
const defineConfig = require('stylelint-define-config')

/// <reference types="@stylelint-types/stylelint-scss" />

module.exports = defineConfig({
  extends: 'stylelint-config-standard',
  rules: {
    // ...rules
  }
})

Why?

Improve your stylelint configuration experience with:

  • auto-suggestions
  • type checking (Use // @ts-check at the first line in your stylelint.config.[c,m]js)
  • documentation

Community Plugins

Want to support your own plugin?

⚠️ This feature is very new and requires the support of the respective plugin owners

Add a declare module to your plugin package like this:

declare module 'stylelint-define-config' {
  export interface CustomRuleOptions {
    /**
     * Require or disallow a newline after the closing brace of `@else` statements.
     *
     * @see [at-else-closing-brace-newline-after](https://github.com/stylelint-scss/stylelint-scss/tree/master/src/rules/at-else-closing-brace-space-after)
     */
    'scss/at-else-closing-brace-newline-after': AtElseClosingBraceNewlineAfterOptions

    // ... more Rules
  }
}
import { RuleConfig } from 'stylelint-define-config'

export type AtElseClosingBraceNewlineAfterOptions = RuleConfig<'always-last-in-chain', {
  disableFix?: boolean
}>

There are other interfaces that can be extended.

  • CustomExtends
  • CustomPlugins
  • CustomSyntax

LICENSE

MIT

Package Sidebar

Install

npm i stylelint-define-config

Weekly Downloads

76

Version

1.3.0

License

MIT

Unpacked Size

141 kB

Total Files

6

Last publish

Collaborators

  • pengzhanbo