diff --git a/packages/stylelint-config-kyt/.stylelintrc.js b/packages/stylelint-config-kyt/.stylelintrc.js new file mode 100644 index 000000000..e3beaa01d --- /dev/null +++ b/packages/stylelint-config-kyt/.stylelintrc.js @@ -0,0 +1,30 @@ +modules.exports = { + extends: 'stylelint-config-standard', + + rules: { + 'string-quotes': 'single', + 'selector-max-id': 0, + 'property-no-unknown': [true, { ignoreProperties: ['composes'] }], + 'selector-pseudo-class-no-unknown': [ + true, + { + ignorePseudoClasses: ['export', 'import', 'global', 'local'], + }, + ], + 'function-url-scheme-blacklist': 'never', + 'property-no-vendor-prefix': true, + 'selector-no-vendor-prefix': true, + 'selector-class-pattern': [ + '^[a-zA-Z0-9_]+$', + { + message: 'Selector should be alhpanumeric, without hyphens [stylelint-config-kyt]', + }, + ], + 'at-rule-no-unknown': [ + true, + { + ignoreAtRules: ['extend', 'include', 'mixin', 'if', 'else', 'for'], + }, + ], + }, +}; diff --git a/packages/stylelint-config-kyt/README.md b/packages/stylelint-config-kyt/README.md index 42b4ba9f9..d2ab58fd2 100644 --- a/packages/stylelint-config-kyt/README.md +++ b/packages/stylelint-config-kyt/README.md @@ -1,30 +1,26 @@ -# kyt Stylelint Linter and CSS/Sass Style Guide +# NYT Stylelint and SCSS Style Guide This is an extension of [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard) with some overrides for CSS/Sass Modules. -## Table of Contents - -1. [Install](#install) -1. [CSS + Sass Guide](#css--sass-guide) - - [Formatting](#formatting) - - [Comments](#comments) - - [ID Selectors](#id-selectors) - - [Syntax](#syntax) - - [Ordering](#ordering-of-property-declarations) - - [Variables](#variables) - - [Mixins](#mixins) -1. [Changelog](#changelog) - ## Install If you want to install this linter extension, follow these install instructions. -1. Install the `stylelint-config-kyt` npm package: - ``` - npm i --save-dev stylelint stylelint-config-kyt stylelint-config-standard - ``` -1. Add a `.stylelintrc` file to your project's root -1. Add configuration: +``` +yarn add --dev stylelint@13.6.1 \ + stylelint-config-standard@20.0.0 \ + stylelint-config-kyt + +// or + +npm i --save-dev --save-exact stylelint@13.6.1 \ + stylelint-config-standard@20.0.0 \ + stylelint-config-kyt +``` + +## Configuration + +Add a `.stylelintrc` file to your project's root with these contents: ```json { @@ -35,8 +31,6 @@ If you want to install this linter extension, follow these install instructions. ## CSS + Sass Guide -The following guide is best used with the `kyt` linter against CSS/Sass Modules. - ### Formatting - Use soft tabs (2 spaces) for indentation. @@ -102,8 +96,8 @@ You should never define an ID selector in a CSS Module. ### Ordering of property declarations -1. `@include` or `composes` declarations -2. Property declarations in alphabetical order +* `@include` or `composes` declarations +* Property declarations in alphabetical order ```scss .btnGreen { @@ -115,20 +109,20 @@ You should never define an ID selector in a CSS Module. } ``` -3. Nested pseudo-selectors +* Nested pseudo-selectors - Nested pseudo-selectors go last, and nothing goes after them. + Nested pseudo-selectors go last, and nothing goes after them. - ```scss - .btn { - @include color(red); - font-weight: bold; + ```scss + .btn { + @include color(red); + font-weight: bold; - &:hover { - cursor: pointer; - } + &:hover { + cursor: pointer; } - ``` + } + ``` ### Variables diff --git a/packages/stylelint-config-kyt/package.json b/packages/stylelint-config-kyt/package.json index 3b062395b..88882129a 100644 --- a/packages/stylelint-config-kyt/package.json +++ b/packages/stylelint-config-kyt/package.json @@ -1,11 +1,15 @@ { "name": "stylelint-config-kyt", "version": "1.0.0-beta.40.2", - "main": "stylelintrc.json", + "main": ".stylelintrc.js", "description": "StyleLint configuration for kyt projects.", "author": "NYTimes", "license": "Apache-2.0", - "repository": "git+https://github.com/nytimes/kyt/packages/stylelint-config-kyt", + "repository": { + "type" : "git", + "url" : "https://github.com/nytimes/kyt.git", + "directory": "packages/stylelint-config-kyt" + }, "bugs": "https://github.com/nytimes/kyt/issues", "homepage": "https://github.com/nytimes/kyt#readme", "peerDependencies": { diff --git a/packages/stylelint-config-kyt/stylelintrc.json b/packages/stylelint-config-kyt/stylelintrc.json deleted file mode 100644 index f0e33e3b6..000000000 --- a/packages/stylelint-config-kyt/stylelintrc.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "extends": "stylelint-config-standard", - - "rules": { - "string-quotes": "single", - "selector-max-id": 0, - "property-no-unknown": [true, { "ignoreProperties": ["composes"] }], - "selector-pseudo-class-no-unknown": [ - true, - { - "ignorePseudoClasses": ["export", "import", "global", "local"] - } - ], - "function-url-scheme-blacklist": "never", - "property-no-vendor-prefix": true, - "selector-no-vendor-prefix": true, - "selector-class-pattern": [ - "^[a-zA-Z0-9_]+$", - { - "message": "Selector should be alhpanumeric, without hyphens [stylelint-config-kyt]" - } - ], - "at-rule-no-unknown": [ true, { - "ignoreAtRules": [ - "extend", - "include", - "mixin", - "if", - "else", - "for" - ] - }] - } -}