1.0.1 • Published 10 months ago

@frontendfixer/stylelint-config-standard v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@frontendfixer/stylelint-config-standard

npm GitHub Workflow Status (with event) GitHub

Stylelint config with standard rules and useful plugins


Packages included


Usages

Installation

yarn add -D postcss^8.4.27 stylelint^15.10.2 @frontendfixer/stylelint-config-standard

Configuration

Create a Stylelint config file with .stylelintrc or .stylelintrc.json and put this lint

{
  "extends": "@frontendfixer/stylelint-config-standard"
}

or you can also put it in your package.json above scripts or higher position

"stylelint": {
    "extends": "@frontendfixer/stylelint-config-standard"
  }

Add script

You can add two scripts to your package.json to lint and/or fix:

"scripts": {
  "lint": "stylelint '**/*.{css,scss}'",
  "lint:fix": "stylelint '**/*.{css,scss}' --fix",
},
  • Now you can manually lint your code by running yarn run lint and fix all fixable issues with yarn run lint:fix. You probably want your editor to do this though.

Auto fix lint error with VSCode

You should read this entire thing. Serious!

Once you have done one, or both, of the above installs. You probably want your editor to lint and fix for you. Here are the instructions for VS Code:

  1. Install the vscode-stylelint
  2. Now we need to setup some VS Code settings via Code/FilePreferencesSettings. It's easier to enter these settings while editing the settings.json file, so click the Open (Open Settings) icon in the top right corner:
// disable the built-in CSS, Less, and SCSS linters:
"css.validate": false,
"scss.validate": false,
// enable stylelint
"stylelint.validate": ["css", "scss"],
// tell the Stylelint plugin to run on save
"editor.codeActionsOnSave": {
  "source.fixAll.stylelint": true
},