diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2477938 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = false + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25c8fdb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..74f59ff --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020, Aymeric Assier and Julien Martins Da Costa. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6dd786e --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +# Stylelint config + +> The recommended stylelint config for scss files. + +It turns on all the [_possible errors_](https://stylelint.io/user-guide/rules#possible-errors) rules within stylelint. + +- **SCSS Property**: Use `stylelint-scss` plugin. Explore this project on [Github](https://github.com/kristerkari/stylelint-scss). + +- **Property Ordering**: Extends `stylelint-config-property-sort-order-smacss`. Refer to [here](https://github.com/cahamilton/css-property-sort-order-smacss/blob/master/index.js) for the comprehensive list of property orders. + +## Installation + +```bash +npm install stylelint stylelint-scss stylelint-config-property-sort-order-smacss stylelint-order @wide/stylelint-config --save-dev +``` + +## Usage + +If you've installed `@wide/stylelint-config` locally within your project, just set your `stylelint` config to: + +```json +{ + "extends": "@wide/stylelint-config" +} +``` + +### Extending the config + +Simply add a `"rules"` key to your config, then add your overrides and additions there. + +For example, to change the `at-rule-no-unknown` rule to use its `ignoreAtRules` option, turn off the `block-no-empty` rule, and add the `unit-whitelist` rule: + +```json +{ + "extends": "@wide/stylelint-config", + "rules": { + "at-rule-no-unknown": [ + true, + { + "ignoreAtRules": ["extends"] + } + ], + "block-no-empty": null, + "unit-whitelist": ["em", "rem", "s"] + } +} +``` + +### Stylelint CLI +Use Stylelint CLI to check the supported files. Drop this line into your package.json and customize it as your needs: + +```json +{ + "scripts": { + "lint:scss": "stylelint src/**/*.scss --formatter verbose" + } +} +``` + +## Thanks +- [stylelint](https://github.com/stylelint/stylelint) +- [stylelint-config-property-sort-order-smacss](https://github.com/cahamilton/stylelint-config-property-sort-order-smacss) +- [stylelint-order](https://github.com/hudochenkov/stylelint-order) +- [stylelint-scss](https://github.com/kristerkari/stylelint-scss) + +## Authors + +- **Aymeric Assier** - [github.com/myeti](https://github.com/myeti) +- **Julien Martins Da Costa** - [github.com/jdacosta](https://github.com/jdacosta) + +### Contributors + +- **Sébastien Robillard** - [github.com/robiseb](https://github.com/robiseb) + +## License + +This project is licensed under the MIT License - see the [licence](licence) file for details diff --git a/index.js b/index.js new file mode 100644 index 0000000..6d78851 --- /dev/null +++ b/index.js @@ -0,0 +1,359 @@ +"use strict"; + +module.exports = { + extends: "stylelint-config-property-sort-order-smacss", + plugins: ["stylelint-order", "stylelint-scss"], + rules: { + "at-rule-blacklist": ["debug"], + "at-rule-empty-line-before": [ + "always", + { + "ignore": [ + "after-comment", + "blockless-after-same-name-blockless", + "first-nested" + ], + "ignoreAtRules": [ + "if", + "else" + ] + } + ], + "at-rule-name-case": "lower", + "at-rule-name-newline-after": "always-multi-line", + "at-rule-name-space-after": "always-single-line", + "at-rule-no-unknown": null, + "at-rule-no-vendor-prefix": true, + "at-rule-property-requirelist": { + "font-face": [ + "font-display", + "font-family", + "font-style" + ] + }, + "at-rule-semicolon-newline-after": "always", + "at-rule-semicolon-space-before": "never", + "block-no-empty": true, + "block-closing-brace-empty-line-before": "never", + "block-closing-brace-newline-after": [ + "always", + { + "ignoreAtRules": [ + "if", + "else" + ] + } + ], + "block-closing-brace-newline-before": "always", + "block-closing-brace-space-after": "never-single-line", + "block-closing-brace-space-before": "always-single-line", + "block-opening-brace-newline-after": "always", + "block-opening-brace-space-after": "always-single-line", + "block-opening-brace-space-before": "always", + "color-hex-case": "lower", + "color-hex-length": "short", + "color-named": "never", + "color-no-invalid-hex": true, + "comment-empty-line-before": "always", + "comment-no-empty": true, + "comment-whitespace-inside": "always", + "custom-property-empty-line-before": "never", + "declaration-bang-space-after": "never", + "declaration-bang-space-before": "always", + "declaration-block-no-duplicate-properties": [ + true, + { + "ignore": ["consecutive-duplicates-with-different-values"] + } + ], + "declaration-block-no-redundant-longhand-properties": true, + "declaration-block-no-shorthand-property-overrides": true, + "declaration-block-semicolon-newline-after": "always", + "declaration-block-semicolon-newline-before": "never-multi-line", + "declaration-block-semicolon-space-after": "always-single-line", + "declaration-block-semicolon-space-before": "never", + "declaration-block-single-line-max-declarations": 1, + "declaration-block-trailing-semicolon": "always", + "declaration-colon-newline-after": "always-multi-line", + "declaration-colon-space-after": "always-single-line", + "declaration-colon-space-before": "never", + "declaration-empty-line-before": [ + "always", + { + "except": [ + "after-comment", + "after-declaration", + "first-nested" + ] + } + ], + "declaration-property-value-blacklist": { + "border": ["none"], + "border-top": ["none"], + "border-right": ["none"], + "border-bottom": ["none"], + "border-left": ["none"] + }, + "font-family-name-quotes": "always-unless-keyword", + "font-family-no-duplicate-names": true, + "font-family-no-missing-generic-family-keyword": [ + true, + { + "ignoreFontFamilies": [ + "/object-fit/", + "/object-position/" + ] + } + ], + "font-weight-notation": "numeric", + "function-calc-no-invalid": true, + "function-calc-no-unspaced-operator": true, + "function-comma-newline-after": "always-multi-line", + "function-comma-newline-before": "never-multi-line", + "function-comma-space-after": "always-single-line", + "function-comma-space-before": "never", + "function-linear-gradient-no-nonstandard-direction": true, + "function-max-empty-lines": 0, + "function-name-case": "lower", + "function-parentheses-newline-inside": "always-multi-line", + "function-parentheses-space-inside": "never-single-line", + "function-url-no-scheme-relative": true, + "function-url-quotes": "always", + "function-whitespace-after": "always", + "indentation": 2, + "keyframe-declaration-no-important": true, + "keyframes-name-pattern": "^[a-z]+([a-z0-9-]+[a-z0-9]+)?$", + "length-zero-no-unit": true, + "linebreaks": "unix", + "max-empty-lines": 1, + "max-line-length": [ + 140, + { + "ignore": [ + "comments" + ], + "ignorePattern": [ + "/^\\$[0-9,a-z]*/", + "/^@error\\s+/", + "/^@import\\s+/", + "/^@use\\s+/", + "/^@warn\\s+/", + "/https?://[0-9,a-z]*.*/" + ] + } + ], + "max-nesting-depth": [ + 5, + { + "ignoreAtRules": [ + "each", + "media", + "supports", + "include" + ] + } + ], + "media-feature-colon-space-after": "always", + "media-feature-colon-space-before": "never", + "media-feature-name-case": "lower", + "media-feature-name-no-unknown": true, + "media-feature-name-no-vendor-prefix": true, + "media-feature-parentheses-space-inside": "never", + "media-feature-range-operator-space-after": "always", + "media-feature-range-operator-space-before": "always", + "media-query-list-comma-newline-after": "always-multi-line", + "media-query-list-comma-newline-before": "never-multi-line", + "media-query-list-comma-space-after": "always-single-line", + "media-query-list-comma-space-before": "never", + "no-eol-whitespace": true, + "no-empty-first-line": true, + "no-empty-source": true, + "no-extra-semicolons": true, + "no-duplicate-at-import-rules": true, + "no-missing-end-of-source-newline": true, + "no-unknown-animations": true, + "number-leading-zero": "never", + "number-max-precision": 3, + "number-no-trailing-zeros": true, + "order/order": [ + [ + "custom-properties", + "dollar-variables", + { + "type": "at-rule", + "name": "extend" + }, + { + "type": "at-rule", + "name": "include", + "hasBlock": false + }, + "declarations", + { + "type": "at-rule", + "name": "include", + "hasBlock": true + }, + "rules", + { + "type": "at-rule", + "name": "include", + "parameter": "bp", + "hasBlock": true + } + ] + ], + "property-case": "lower", + "property-no-unknown": true, + "property-no-vendor-prefix": true, + "rule-empty-line-before": [ + "always-multi-line", + { + "except": ["first-nested"], + "ignore": ["after-comment"] + } + ], + "selector-attribute-brackets-space-inside": "never", + "selector-attribute-operator-space-after": "never", + "selector-attribute-operator-space-before": "never", + "selector-attribute-quotes": "always", + "selector-class-pattern": [ + "^[a-z0-9\\-]+$", + { + "message": + "Selector should be written in lowercase with hyphens (selector-class-pattern)" + } + ], + "selector-combinator-space-after": "always", + "selector-combinator-space-before": "always", + "selector-descendant-combinator-no-non-space": true, + "selector-list-comma-newline-after": "always", + "selector-list-comma-newline-before": "never-multi-line", + "selector-list-comma-space-after": "always-single-line", + "selector-list-comma-space-before": "never", + "selector-max-attribute": 3, + "selector-max-class": 5, + "selector-max-compound-selectors": 5, + "selector-max-empty-lines": 0, + "selector-max-id": 1, + "selector-max-universal": 1, + "selector-no-vendor-prefix": true, + "selector-pseudo-class-case": "lower", + "selector-pseudo-class-no-unknown": true, + "selector-pseudo-class-parentheses-space-inside": "never", + "selector-pseudo-element-case": "lower", + "selector-pseudo-element-colon-notation": "double", + "selector-pseudo-element-no-unknown": true, + "selector-type-case": "lower", + "shorthand-property-no-redundant-values": true, + "string-no-newline": true, + "string-quotes": "single", + "time-min-milliseconds": 100, + "unit-case": "lower", + "unit-no-unknown": true, + "value-keyword-case": "lower", + "value-list-comma-newline-after": "always-multi-line", + "value-list-comma-newline-before": "never-multi-line", + "value-list-comma-space-after": "always-single-line", + "value-list-comma-space-before": "never", + "value-list-max-empty-lines": 0, + "value-no-vendor-prefix": true, + "scss/at-each-key-value-single-line": true, + "scss/at-else-closing-brace-newline-after": "always-last-in-chain", + "scss/at-else-closing-brace-space-after": "always-intermediate", + "scss/at-else-empty-line-before": "never", + "scss/at-else-if-parentheses-space-before": "always", + "scss/at-extend-no-missing-placeholder": true, + "scss/at-function-parentheses-space-before": "never", + "scss/at-function-pattern": "^[a-z]+([a-z0-9-]+[a-z0-9]+)?$", + "scss/at-if-closing-brace-newline-after": "always-last-in-chain", + "scss/at-if-closing-brace-space-after": "always-intermediate", + "scss/at-if-no-null": true, + "scss/at-import-no-partial-leading-underscore": true, + "scss/at-import-partial-extension": "never", + "scss/at-mixin-argumentless-call-parentheses": "never", + "scss/at-mixin-parentheses-space-before": "never", + "scss/at-mixin-pattern": "^[a-z]+([a-z0-9-]+[a-z0-9]+)?$", + "scss/at-rule-conditional-no-parentheses": true, + "scss/at-rule-no-unknown": true, + "scss/comment-no-loud": true, + "scss/declaration-nested-properties": "never", + "scss/dimension-no-non-numeric-values": true, + "scss/dollar-variable-colon-space-after": "always", + "scss/dollar-variable-colon-space-before": "never", + "scss/dollar-variable-default": [ + true, + { + "ignore": ["local"] + } + ], + "scss/dollar-variable-empty-line-after": [ + "always", + { + "except": [ + "last-nested", + "before-dollar-variable" + ] + } + ], + "scss/dollar-variable-empty-line-before": [ + "always", + { + "except": [ + "after-comment", + "after-dollar-variable", + "first-nested" + ] + } + ], + "scss/dollar-variable-first-in-block": [ + true, + { + "ignore": [ + "comments", + "imports" + ], + "except": [ + "function", + "mixin", + "root" + ] + } + ], + "scss/dollar-variable-no-missing-interpolation": true, + "scss/dollar-variable-pattern": "^[_]?[a-z]+([a-z0-9-]+[a-z0-9]+)?$", + "scss/double-slash-comment-empty-line-before": [ + "always", + { + "except": ["first-nested"], + "ignore": ["between-comments"] + } + ], + "scss/double-slash-comment-whitespace-inside": "always", + "scss/function-color-relative": true, + "scss/function-quote-no-quoted-strings-inside": true, + "scss/function-unquote-no-unquoted-strings-inside": true, + "scss/map-keys-quotes": "always", + "scss/no-duplicate-dollar-variables": [ + true, + { + "ignoreInside": [ + "at-rule" + ], + "ignoreInsideAtRules": [ + "if", + "else" + ] + } + ], + "scss/no-duplicate-mixins": true, + "scss/no-global-function-names": true, + "scss/operator-no-newline-after": true, + "scss/operator-no-newline-before": true, + "scss/operator-no-unspaced": true, + "scss/partial-no-import": true, + "scss/percent-placeholder-pattern": "^[a-z]+([a-z0-9-]+[a-z0-9]+)?$", + "scss/selector-nest-combinators": "always", + "scss/selector-no-redundant-nesting-selector": true, + } +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..06dc247 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "@wide/stylelint-config", + "version": "2.0.0", + "description": "The recommended stylelint config for scss files", + "license": "MIT", + "author": "Julien Martins Da Costa (https://github.com/jdacosta)", + "contributors": [ + "Aymeric Assier (https://github.com/myeti)", + "Julien Martins Da Costa (https://github.com/jdacosta)", + "Sébastien Robillard (https://github.com/robiseb)" + ], + "repository": { + "type" : "git", + "url" : "https://github.com/wide/stylelint-config.git" + }, + "engines": { + "node": ">=10.13.0" + }, + "peerDependencies": { + "stylelint": "^13.5.0", + "stylelint-config-property-sort-order-smacss": "^6.3.0", + "stylelint-order": "^4.0.0", + "stylelint-scss": "^3.17.2" + } +}