@justeattakeaway/stylelint-config-pie 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js ADDED
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es6: true,
5
+ jest: true,
6
+ node: true,
7
+ },
8
+ extends: [require.resolve('@justeattakeaway/eslint-config-pie/strict')],
9
+ };
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Fixed] - Updating pkg name to use conventional stylelint pkg naming ([#468](https://github.com/justeattakeaway/pie/pull/468)) by [@ashleynolan](https://github.com/ashleynolan)
8
+
9
+ ## 0.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Add missing Volta settings to package.json ([#322](https://github.com/justeattakeaway/pie/pull/322)) by [@fernandofranca](https://github.com/fernandofranca)
14
+
15
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
16
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
17
+
18
+ ## v0.1.0
19
+
20
+ _January 11, 2023_
21
+
22
+ ### Added
23
+
24
+ - Base rules
25
+ - Project skeleton
@@ -0,0 +1,123 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, caste, color, religion, or sexual
11
+ identity and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the overall
27
+ community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or advances of
32
+ any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email address,
36
+ without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement by emailing
64
+ [compliance.global@justeattakeaway.com](mailto:compliance.global@justeattakeaway.com).
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series of
87
+ actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or permanent
94
+ ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within the
114
+ community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.1, available at
120
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121
+
122
+ [homepage]: https://www.contributor-covenant.org
123
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
package/LICENCE.md ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright (c) Just Eat Takeaway
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # stylelint-config-pie
2
+
3
+ [![npm version](https://badge.fury.io/js/@justeattakeaway%stylelint-config-pie.svg)](https://badge.fury.io/js/@justeattakeaway%stylelint-config-pie)
4
+
5
+ > PIE shareable stylelint config.
6
+
7
+ A Stylelint config used in PIE – Just Eat Takeaway’s design system.
8
+
9
+ Use it as is or as a foundation for your own config.
10
+
11
+ To see the rules that this config uses, please read the [config itself](./index.js).
12
+
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @justeattakeaway/stylelint-config-pie --save-dev
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ### Rules
23
+
24
+ Currently there are 3 different sets of rules:
25
+
26
+ 1. `base` - the base rules that we'd advise all projects use and extend as needed.
27
+ 2. `strict` - a smaller collection of _optional_ opinionated rules.
28
+ 3. `ordering` - an even smaller collection of _optional_ rules that specify the ordering of CSS properties.
29
+
30
+ ### In your projects
31
+
32
+ If you've installed `stylelint-config-pie` locally within your project, just set your `stylelint` config to:
33
+
34
+ ```json
35
+ {
36
+ "extends": "@justeattakeaway/stylelint-config-pie/base"
37
+ }
38
+ ```
39
+
40
+ The easiest way to do this is by adding the following section to your package.json:
41
+
42
+ ```json
43
+ "stylelint": {
44
+ "extends": "@justeattakeaway/stylelint-config-pie/base"
45
+ }
46
+ ```
47
+
48
+ You may only want to use a specific ruleset such as `base`, `strict` or `ordering`. If so, simply point to the ones you'd like to use:
49
+
50
+ ```json
51
+ "stylelint": {
52
+ "extends": [
53
+ "@justeattakeaway/stylelint-config-pie/base",
54
+ "@justeattakeaway/stylelint-config-pie/strict",
55
+ "@justeattakeaway/stylelint-config-pie/ordering"
56
+ ]
57
+ }
58
+ ```
59
+
60
+ _Note: `@justeattakeaway/stylelint-config-pie` includes all rules. We would strongly recommend using `@justeattakeaway/stylelint-config-pie/base` and going from there._
61
+
62
+ If you've globally installed `stylelint-config-pie` using the `-g` flag, then you'll need to use the absolute path to `stylelint-config-pie` in your config e.g.
63
+
64
+ ```json
65
+ {
66
+ "extends": "/absolute/path/to/@justeattakeaway/stylelint-config-pie/base"
67
+ }
68
+ ```
69
+
70
+ ### Extending the config
71
+
72
+ Simply add a `"rules"` key to your config, then add your overrides and additions there.
73
+
74
+ For example, to change the `indentation` to tabs, and turn off the `number-leading-zero` rule:
75
+
76
+ ```json
77
+ {
78
+ "extends": "@justeattakeaway/stylelint-config-pie/base",
79
+ "rules": {
80
+ "indentation": "tab",
81
+ "number-leading-zero": null
82
+ }
83
+ }
84
+ ```
85
+
86
+ ### Documentation
87
+
88
+ #### Configured Lints
89
+
90
+ `stylelint-config-pie` is a great foundation for your own config. Here is a list of the rules turned on in this config, and what they do:
91
+
92
+ ### Base
93
+ - [alpha-value-notation](https://stylelint.io/user-guide/rules/alpha-value-notation/)
94
+ - [at-rule-empty-line-before](https://stylelint.io/user-guide/rules/at-rule-empty-line-before/)
95
+ - [at-rule-name-case](https://stylelint.io/user-guide/rules/at-rule-name-case/)
96
+ - [at-rule-name-space-after](https://stylelint.io/user-guide/rules/at-rule-name-space-after/)
97
+ - [at-rule-no-vendor-prefix](https://stylelint.io/user-guide/rules/at-rule-no-vendor-prefix/)
98
+ - [block-closing-brace-newline-after](https://stylelint.io/user-guide/rules/block-closing-brace-newline-after/)
99
+ - [block-closing-brace-newline-before](https://stylelint.io/user-guide/rules/block-closing-brace-newline-before/)
100
+ - [block-closing-brace-space-before](https://stylelint.io/user-guide/rules/block-closing-brace-space-before/)
101
+ - [block-opening-brace-newline-after](https://stylelint.io/user-guide/rules/block-opening-brace-newline-after/)
102
+ - [block-opening-brace-space-after](https://stylelint.io/user-guide/rules/block-opening-brace-space-after/)
103
+ - [block-opening-brace-space-before](https://stylelint.io/user-guide/rules/block-opening-brace-space-before/)
104
+ - [color-function-notation](https://stylelint.io/user-guide/rules/color-function-notation/)
105
+ - [color-hex-case](https://stylelint.io/user-guide/rules/color-hex-case/)
106
+ - [color-hex-length](https://stylelint.io/user-guide/rules/color-hex-length/)
107
+ - [color-no-invalid-hex](https://stylelint.io/user-guide/rules/color-no-invalid-hex/)
108
+ - [comment-empty-line-before](https://stylelint.io/user-guide/rules/comment-empty-line-before/)
109
+ - [comment-whitespace-inside](https://stylelint.io/user-guide/rules/comment-whitespace-inside/)
110
+ - [declaration-bang-space-after](https://stylelint.io/user-guide/rules/declaration-bang-space-after/)
111
+ - [declaration-bang-space-before](https://stylelint.io/user-guide/rules/declaration-bang-space-before/)
112
+ - [declaration-block-no-duplicate-properties](https://stylelint.io/user-guide/rules/declaration-block-no-duplicate-properties/)
113
+ - [declaration-block-no-shorthand-property-overrides](https://stylelint.io/user-guide/rules/declaration-block-no-shorthand-property-overrides/)
114
+ - [declaration-block-semicolon-newline-after](https://stylelint.io/user-guide/rules/declaration-block-semicolon-newline-after/)
115
+ - [declaration-block-semicolon-newline-before](https://stylelint.io/user-guide/rules/declaration-block-semicolon-newline-before/)
116
+ - [declaration-block-semicolon-space-before](https://stylelint.io/user-guide/rules/declaration-block-semicolon-space-before/)
117
+ - [declaration-block-trailing-semicolon](https://stylelint.io/user-guide/rules/declaration-block-trailing-semicolon/)
118
+ - [declaration-colon-newline-after](https://stylelint.io/user-guide/rules/declaration-colon-newline-after/)
119
+ - [declaration-colon-space-after](https://stylelint.io/user-guide/rules/declaration-colon-space-after/)
120
+ - [declaration-colon-space-before](https://stylelint.io/user-guide/rules/declaration-colon-space-before/)
121
+ - [font-family-name-quotes](https://stylelint.io/user-guide/rules/font-family-name-quotes/)
122
+ - [font-weight-notation](https://stylelint.io/user-guide/rules/font-weight-notation/)
123
+ - [function-calc-no-unspaced-operator](https://stylelint.io/user-guide/rules/function-calc-no-unspaced-operator/)
124
+ - [function-comma-newline-after](https://stylelint.io/user-guide/rules/function-comma-newline-after/)
125
+ - [function-comma-newline-before](https://stylelint.io/user-guide/rules/function-comma-newline-before/)
126
+ - [function-comma-space-after](https://stylelint.io/user-guide/rules/function-comma-space-after/)
127
+ - [function-comma-space-before](https://stylelint.io/user-guide/rules/function-comma-space-before/)
128
+ - [function-linear-gradient-no-nonstandard-direction](https://stylelint.io/user-guide/rules/function-linear-gradient-no-nonstandard-direction/)
129
+ - [function-name-case](https://stylelint.io/user-guide/rules/function-name-case/)
130
+ - [function-parentheses-space-inside](https://stylelint.io/user-guide/rules/function-parentheses-space-inside/)
131
+ - [function-url-quotes](https://stylelint.io/user-guide/rules/function-url-quotes/)
132
+ - [function-whitespace-after](https://stylelint.io/user-guide/rules/function-whitespace-after/)
133
+ - [indentation](https://stylelint.io/user-guide/rules/indentation/)
134
+ - [keyframes-name-pattern](https://stylelint.io/user-guide/rules/keyframes-name-pattern/)
135
+ - [length-zero-no-unit](https://stylelint.io/user-guide/rules/length-zero-no-unit/)
136
+ - [max-empty-lines](https://stylelint.io/user-guide/rules/max-empty-lines/)
137
+ - [media-feature-colon-space-after](https://stylelint.io/user-guide/rules/media-feature-colon-space-after/)
138
+ - [media-feature-colon-space-before](https://stylelint.io/user-guide/rules/media-feature-colon-space-before/)
139
+ - [media-feature-name-case](https://stylelint.io/user-guide/rules/media-feature-name-case/)
140
+ - [media-feature-name-no-vendor-prefix](https://stylelint.io/user-guide/rules/media-feature-name-no-vendor-prefix/)
141
+ - [media-feature-parentheses-space-inside](https://stylelint.io/user-guide/rules/media-feature-parentheses-space-inside/)
142
+ - [media-feature-range-operator-space-after](https://stylelint.io/user-guide/rules/media-feature-range-operator-space-after/)
143
+ - [media-feature-range-operator-space-before](https://stylelint.io/user-guide/rules/media-feature-range-operator-space-before/)
144
+ - [media-query-list-comma-newline-before](https://stylelint.io/user-guide/rules/media-query-list-comma-newline-before/)
145
+ - [media-query-list-comma-space-after](https://stylelint.io/user-guide/rules/media-query-list-comma-space-after/)
146
+ - [media-query-list-comma-space-before](https://stylelint.io/user-guide/rules/media-query-list-comma-space-before/)
147
+ - [no-duplicate-selectors](https://stylelint.io/user-guide/rules/no-duplicate-selectors/)
148
+ - [no-eol-whitespace](https://stylelint.io/user-guide/rules/no-eol-whitespace/)
149
+ - [no-missing-end-of-source-newline](https://stylelint.io/user-guide/rules/no-missing-end-of-source-newline/)
150
+ - [number-leading-zero](https://stylelint.io/user-guide/rules/number-leading-zero/)
151
+ - [number-max-precision](https://stylelint.io/user-guide/rules/number-max-precision/)
152
+ - [number-no-trailing-zeros](https://stylelint.io/user-guide/rules/number-no-trailing-zeros/)
153
+ - [property-case](https://stylelint.io/user-guide/rules/property-case/)
154
+ - [property-no-unknown](https://stylelint.io/user-guide/rules/property-no-unknown/)
155
+ - [property-no-vendor-prefix](https://stylelint.io/user-guide/rules/property-no-vendor-prefix/)
156
+ - [rule-empty-line-before](https://stylelint.io/user-guide/rules/rule-empty-line-before/)
157
+ - [scss/at-else-closing-brace-newline-after](https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-else-closing-brace-newline-after/README.md)
158
+ - [scss/at-else-closing-brace-space-after](https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-else-closing-brace-space-after/README.md)
159
+ - [scss/at-else-empty-line-before](https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-else-empty-line-before)
160
+ - [scss/at-else-if-parentheses-space-before](https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-else-if-parentheses-space-before)
161
+ - [scss/at-if-closing-brace-newline-after](https://github.com/stylelint-scss/stylelint-scss/blob/master/src/rules/at-if-closing-brace-newline-after)
162
+ - [selector-attribute-quotes](https://stylelint.io/user-guide/rules/selector-attribute-quotes/)
163
+ - [selector-class-pattern](https://stylelint.io/user-guide/rules/selector-class-pattern/)
164
+ - [selector-combinator-space-after](https://stylelint.io/user-guide/rules/selector-combinator-space-after/)
165
+ - [selector-combinator-space-before](https://stylelint.io/user-guide/rules/selector-combinator-space-before/)
166
+ - [selector-descendant-combinator-no-non-space](https://stylelint.io/user-guide/rules/selector-descendant-combinator-no-non-space/)
167
+ - [selector-list-comma-newline-after](https://stylelint.io/user-guide/rules/selector-list-comma-newline-after/)
168
+ - [selector-list-comma-newline-before](https://stylelint.io/user-guide/rules/selector-list-comma-newline-before/)
169
+ - [selector-list-comma-space-before](https://stylelint.io/user-guide/rules/selector-list-comma-space-before/)
170
+ - [selector-max-empty-lines](https://stylelint.io/user-guide/rules/selector-max-empty-lines/)
171
+ - [selector-max-universal](https://stylelint.io/user-guide/rules/selector-max-universal/)
172
+ - [selector-no-vendor-prefix](https://stylelint.io/user-guide/rules/selector-no-vendor-prefix/)
173
+ - [selector-pseudo-element-colon-notation](https://stylelint.io/user-guide/rules/selector-pseudo-element-colon-notation/)
174
+ - [selector-type-case](https://stylelint.io/user-guide/rules/selector-type-case/)
175
+ - [string-quotes](https://stylelint.io/user-guide/rules/string-quotes/)
176
+ - [unit-no-unknown](https://stylelint.io/user-guide/rules/unit-no-unknown/)
177
+ - [value-list-comma-newline-after](https://stylelint.io/user-guide/rules/value-list-comma-newline-after/)
178
+ - [value-list-comma-newline-before](https://stylelint.io/user-guide/rules/value-list-comma-newline-before/)
179
+ - [value-list-comma-space-after](https://stylelint.io/user-guide/rules/value-list-comma-space-after/)
180
+ - [value-list-comma-space-before](https://stylelint.io/user-guide/rules/value-list-comma-space-before/)
181
+ - [value-no-vendor-prefix](https://stylelint.io/user-guide/rules/value-no-vendor-prefix/)
182
+
183
+ ### Strict
184
+ - [color-named](https://stylelint.io/user-guide/rules/color-named/)
185
+ - [max-nesting-depth](https://stylelint.io/user-guide/rules/max-nesting-depth/)
186
+ - [media-query-list-comma-newline-after](https://stylelint.io/user-guide/rules/media-query-list-comma-newline-after/)
187
+ - [selector-max-compound-selectors](https://stylelint.io/user-guide/rules/selector-max-compound-selectors/)
188
+ - [selector-max-id](https://stylelint.io/user-guide/rules/selector-max-id/)
189
+
190
+ ### Ordering
191
+ - [order/order](https://github.com/hudochenkov/stylelint-order/blob/master/rules/order/README.md)
192
+ - [order/properties-order](https://github.com/hudochenkov/stylelint-order/blob/master/rules/properties-order/README.md)
193
+
194
+ ## [Changelog](CHANGELOG.md)
@@ -0,0 +1,74 @@
1
+ const stylelint = require('stylelint');
2
+ const baseConfig = require('../../rules/base');
3
+
4
+ describe('base Stylelint rules', () => {
5
+ describe('alpha-value-notation', () => {
6
+ describe('valid CSS', () => {
7
+ // this is very ugly but allows the template string to not flag new line and indentation errors
8
+ const validCSS = `a {
9
+ color: rgb(0, 0, 0, 0.5);
10
+ }
11
+ `;
12
+
13
+ let result;
14
+
15
+ beforeEach(() => {
16
+ result = stylelint.lint({
17
+ code: validCSS,
18
+ config: baseConfig
19
+ });
20
+ });
21
+
22
+ it('did not error', () => result.then(data => expect(data.errored).toBeFalsy()));
23
+
24
+ it('flags no warnings', () => result.then(data => (
25
+ expect(data.results[0].warnings.length).toBe(0)
26
+ )));
27
+ });
28
+
29
+ describe('invalid CSS', () => {
30
+ // this is very ugly but allows the template string to not flag new line and indentation errors
31
+ const invalidCSS = `a {
32
+ color: rgb(0, 0, 0, 50%);
33
+ }
34
+ `;
35
+
36
+ let result;
37
+
38
+ beforeEach(() => {
39
+ result = stylelint.lint({
40
+ code: invalidCSS,
41
+ config: baseConfig
42
+ });
43
+ });
44
+
45
+ it('did error', () => result.then(data => (
46
+ expect(data.errored).toBeTruthy()
47
+ )));
48
+
49
+ it('flags one warning', () => result.then(data => (
50
+ expect(data.results[0].warnings.length).toBe(1)
51
+ )));
52
+
53
+ it('correct warning text', () => result.then(data => (
54
+ expect(data.results[0].warnings[0].text).toBe('Expected "50%" to be "0.5" (alpha-value-notation)')
55
+ )));
56
+
57
+ it('correct rule flagged', () => result.then(data => (
58
+ expect(data.results[0].warnings[0].rule).toBe('alpha-value-notation')
59
+ )));
60
+
61
+ it('correct severity flagged', () => result.then(data => (
62
+ expect(data.results[0].warnings[0].severity).toBe('error')
63
+ )));
64
+
65
+ it('correct line number', () => result.then(data => (
66
+ expect(data.results[0].warnings[0].line).toBe(2)
67
+ )));
68
+
69
+ it('correct column number', () => result.then(data => (
70
+ expect(data.results[0].warnings[0].column).toBe(25)
71
+ )));
72
+ });
73
+ });
74
+ });
@@ -0,0 +1,74 @@
1
+ const stylelint = require('stylelint');
2
+ const strictConfig = require('../../rules/strict');
3
+
4
+ describe('strict Stylelint rules', () => {
5
+ describe('color-named', () => {
6
+ describe('valid CSS', () => {
7
+ // this is very ugly but allows the template string to not flag new line and indentation errors
8
+ const validCSS = `a {
9
+ color: #FF0000;
10
+ }
11
+ `;
12
+
13
+ let result;
14
+
15
+ beforeEach(() => {
16
+ result = stylelint.lint({
17
+ code: validCSS,
18
+ config: strictConfig
19
+ });
20
+ });
21
+
22
+ it('did not error', () => result.then(data => expect(data.errored).toBeFalsy()));
23
+
24
+ it('flags no warnings', () => result.then(data => (
25
+ expect(data.results[0].warnings.length).toBe(0)
26
+ )));
27
+ });
28
+
29
+ describe('invalid CSS', () => {
30
+ // this is very ugly but allows the template string to not flag new line and indentation errors
31
+ const invalidCSS = `a {
32
+ color: red;
33
+ }
34
+ `;
35
+
36
+ let result;
37
+
38
+ beforeEach(() => {
39
+ result = stylelint.lint({
40
+ code: invalidCSS,
41
+ config: strictConfig
42
+ });
43
+ });
44
+
45
+ it('did error', () => result.then(data => (
46
+ expect(data.errored).toBeTruthy()
47
+ )));
48
+
49
+ it('flags one warning', () => result.then(data => (
50
+ expect(data.results[0].warnings.length).toBe(1)
51
+ )));
52
+
53
+ it('correct warning text', () => result.then(data => (
54
+ expect(data.results[0].warnings[0].text).toBe('Unexpected named color "red" (color-named)')
55
+ )));
56
+
57
+ it('correct rule flagged', () => result.then(data => (
58
+ expect(data.results[0].warnings[0].rule).toBe('color-named')
59
+ )));
60
+
61
+ it('correct severity flagged', () => result.then(data => (
62
+ expect(data.results[0].warnings[0].severity).toBe('error')
63
+ )));
64
+
65
+ it('correct line number', () => result.then(data => (
66
+ expect(data.results[0].warnings[0].line).toBe(2)
67
+ )));
68
+
69
+ it('correct column number', () => result.then(data => (
70
+ expect(data.results[0].warnings[0].column).toBe(12)
71
+ )));
72
+ });
73
+ });
74
+ });
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ extends: [
3
+ './rules/base.js',
4
+ './rules/strict.js',
5
+ './rules/ordering.js'
6
+ ]
7
+ };
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@justeattakeaway/stylelint-config-pie",
3
+ "version": "0.2.0",
4
+ "description": "Shareable Stylelint config for use with any front-end web projects across JET.",
5
+ "license": "Apache-2.0",
6
+ "keywords": [
7
+ "PIE",
8
+ "stylelint",
9
+ "stylelint-config",
10
+ "standard"
11
+ ],
12
+ "author": "",
13
+ "exports": {
14
+ ".": "./index.js",
15
+ "./base": "./rules/base.js",
16
+ "./strict": "./rules/strict.js",
17
+ "./ordering": "./rules/ordering.js"
18
+ },
19
+ "peerDependencies": {
20
+ "stylelint": "14.x",
21
+ "stylelint-config-standard-scss": "5.x",
22
+ "stylelint-order": "5.x"
23
+ },
24
+ "scripts": {
25
+ "test": "run -T jest"
26
+ },
27
+ "jest": {
28
+ "testEnvironment": "jsdom"
29
+ },
30
+ "volta": {
31
+ "extends": "../../../package.json"
32
+ }
33
+ }
package/rules/base.js ADDED
@@ -0,0 +1,124 @@
1
+ module.exports = {
2
+ extends: 'stylelint-config-standard-scss',
3
+ rules: {
4
+ 'alpha-value-notation': 'number',
5
+ 'at-rule-empty-line-before': [
6
+ 'always',
7
+ {
8
+ except: ['blockless-after-blockless', 'first-nested'],
9
+ ignore: ['after-comment'],
10
+ ignoreAtRules: ['if', 'else']
11
+ }
12
+ ],
13
+ 'at-rule-name-case': 'lower',
14
+ 'at-rule-name-space-after': 'always',
15
+ 'at-rule-no-vendor-prefix': true,
16
+ 'block-closing-brace-newline-after': [
17
+ 'always',
18
+ {
19
+ ignoreAtRules: ['if', 'else']
20
+ }
21
+ ],
22
+ 'block-closing-brace-newline-before': 'always',
23
+ 'block-closing-brace-space-before': 'always-single-line',
24
+ 'block-opening-brace-newline-after': 'always',
25
+ 'block-opening-brace-space-after': 'always-single-line',
26
+ 'block-opening-brace-space-before': 'always',
27
+ 'color-function-notation': 'legacy',
28
+ 'color-hex-case': 'lower',
29
+ 'color-hex-length': 'short',
30
+ 'color-no-invalid-hex': true,
31
+ 'comment-empty-line-before': [
32
+ 'always',
33
+ {
34
+ except: ['first-nested'],
35
+ ignore: ['stylelint-commands']
36
+ }
37
+ ],
38
+ 'comment-whitespace-inside': 'always',
39
+ 'declaration-bang-space-after': 'never',
40
+ 'declaration-bang-space-before': 'always',
41
+ 'declaration-block-no-duplicate-properties': [
42
+ true, {
43
+ ignore: ['consecutive-duplicates-with-different-values']
44
+ }
45
+ ],
46
+ 'declaration-block-no-shorthand-property-overrides': true,
47
+ 'declaration-block-semicolon-newline-after': 'always',
48
+ 'declaration-block-semicolon-newline-before': 'never-multi-line',
49
+ 'declaration-block-semicolon-space-before': 'never',
50
+ 'declaration-block-trailing-semicolon': 'always',
51
+ 'declaration-colon-newline-after': 'always-multi-line',
52
+ 'declaration-colon-space-after': 'always-single-line',
53
+ 'declaration-colon-space-before': 'never',
54
+ 'font-family-name-quotes': 'always-where-recommended',
55
+ 'font-weight-notation': 'numeric',
56
+ 'function-calc-no-unspaced-operator': true,
57
+ 'function-comma-newline-after': 'never-multi-line',
58
+ 'function-comma-newline-before': 'never-multi-line',
59
+ 'function-comma-space-after': 'always',
60
+ 'function-comma-space-before': 'never',
61
+ 'function-linear-gradient-no-nonstandard-direction': true,
62
+ 'function-name-case': 'lower',
63
+ 'function-parentheses-space-inside': 'never',
64
+ 'function-url-quotes': 'always',
65
+ 'function-whitespace-after': 'always',
66
+ indentation: 4,
67
+ 'keyframes-name-pattern': '^([a-z0-9]+)(((([A-Z]){1}([a-z0-9]+))?)+)',
68
+ 'length-zero-no-unit': true,
69
+ 'max-empty-lines': 2,
70
+ 'media-feature-colon-space-after': 'always',
71
+ 'media-feature-colon-space-before': 'never',
72
+ 'media-feature-name-case': 'lower',
73
+ 'media-feature-name-no-vendor-prefix': true,
74
+ 'media-feature-parentheses-space-inside': 'never',
75
+ 'media-feature-range-operator-space-after': 'always',
76
+ 'media-feature-range-operator-space-before': 'always',
77
+ 'media-query-list-comma-newline-before': null,
78
+ 'media-query-list-comma-space-after': 'always-single-line',
79
+ 'media-query-list-comma-space-before': 'never',
80
+ 'no-duplicate-selectors': null,
81
+ 'no-eol-whitespace': true,
82
+ 'no-missing-end-of-source-newline': true,
83
+ 'number-leading-zero': 'always',
84
+ 'number-max-precision': 3,
85
+ 'number-no-trailing-zeros': true,
86
+ 'property-case': 'lower',
87
+ 'property-no-unknown': true,
88
+ // TODO - we need to figure out what exceptions to add to this
89
+ 'property-no-vendor-prefix': null,
90
+ 'rule-empty-line-before': [
91
+ 'always',
92
+ {
93
+ except: ['first-nested'],
94
+ ignore: ['after-comment']
95
+ }
96
+ ],
97
+ 'scss/at-else-closing-brace-newline-after': 'always-last-in-chain',
98
+ 'scss/at-else-closing-brace-space-after': 'always-intermediate',
99
+ 'scss/at-else-empty-line-before': 'never',
100
+ 'scss/at-else-if-parentheses-space-before': 'always',
101
+ 'scss/at-if-closing-brace-newline-after': 'always-last-in-chain',
102
+ 'selector-attribute-quotes': 'always',
103
+ 'selector-class-pattern': null,
104
+ 'selector-combinator-space-after': 'always',
105
+ 'selector-combinator-space-before': 'always',
106
+ 'selector-descendant-combinator-no-non-space': true,
107
+ 'selector-list-comma-newline-after': 'always',
108
+ 'selector-list-comma-newline-before': 'never-multi-line',
109
+ 'selector-list-comma-space-before': 'never',
110
+ 'selector-max-empty-lines': 0,
111
+ // TODO - Test * > * works
112
+ 'selector-max-universal': [1, { ignoreAfterCombinators: ['>'] }],
113
+ 'selector-no-vendor-prefix': true,
114
+ 'selector-pseudo-element-colon-notation': 'single',
115
+ 'selector-type-case': 'lower',
116
+ 'string-quotes': 'single',
117
+ 'unit-no-unknown': true,
118
+ 'value-list-comma-newline-after': 'always-multi-line',
119
+ 'value-list-comma-newline-before': 'never-multi-line',
120
+ 'value-list-comma-space-after': 'always-single-line',
121
+ 'value-list-comma-space-before': 'never',
122
+ 'value-no-vendor-prefix': true
123
+ }
124
+ };
@@ -0,0 +1,232 @@
1
+ module.exports = {
2
+ plugins: ['stylelint-order'],
3
+ rules: {
4
+ 'order/order': [
5
+ 'custom-properties',
6
+ 'dollar-variables',
7
+ {
8
+ hasBlock: false,
9
+ name: 'include',
10
+ type: 'at-rule'
11
+ },
12
+ 'declarations',
13
+ {
14
+ hasBlock: true,
15
+ name: 'include',
16
+ parameter: /focus|hover/,
17
+ type: 'at-rule'
18
+ },
19
+ {
20
+ hasBlock: true,
21
+ name: 'include',
22
+ parameter: 'active',
23
+ type: 'at-rule'
24
+ },
25
+ {
26
+ selector: '^&:focus|hover$',
27
+ type: 'rule'
28
+ },
29
+ {
30
+ selector: '^&:active$',
31
+ type: 'rule'
32
+ },
33
+ {
34
+ hasBlock: true,
35
+ name: 'include',
36
+ type: 'at-rule'
37
+ },
38
+ {
39
+ name: 'media',
40
+ type: 'at-rule'
41
+ },
42
+ 'rules'
43
+ ],
44
+ 'order/properties-order': [
45
+ 'composes',
46
+ 'content',
47
+ {
48
+ emptyLineBefore: 'always',
49
+ properties: ['position']
50
+ },
51
+ {
52
+ order: 'flexible',
53
+ properties: ['top', 'bottom', 'left', 'right', 'z-index']
54
+ },
55
+ {
56
+ emptyLineBefore: 'always',
57
+ order: 'flexible',
58
+ properties: ['display', 'vertical-align']
59
+ },
60
+ {
61
+ emptyLineBefore: 'always',
62
+ order: 'flexible',
63
+ properties: [
64
+ 'flex',
65
+ 'flex-basis',
66
+ 'flex-direction',
67
+ 'flex-flow',
68
+ 'flex-grow',
69
+ 'flex-shrink',
70
+ 'flex-wrap',
71
+ 'justify-content',
72
+ 'justify-items',
73
+ 'justify-self',
74
+ 'align-content',
75
+ 'align-items',
76
+ 'align-self',
77
+ 'align'
78
+ ]
79
+ },
80
+ {
81
+ emptyLineBefore: 'always',
82
+ order: 'flexible',
83
+ properties: [
84
+ 'width',
85
+ 'height',
86
+ 'min-width',
87
+ 'max-width',
88
+ 'min-height',
89
+ 'max-height',
90
+ 'overflow',
91
+ 'overflow-x',
92
+ 'overflow-y',
93
+ 'box-sizing'
94
+ ]
95
+ },
96
+ {
97
+ emptyLineBefore: 'always',
98
+ order: 'flexible',
99
+ properties: [
100
+ 'margin',
101
+ 'margin-top',
102
+ 'margin-bottom',
103
+ 'margin-left',
104
+ 'margin-right',
105
+ 'padding',
106
+ 'padding-top',
107
+ 'padding-bottom',
108
+ 'padding-left',
109
+ 'padding-right'
110
+ ]
111
+ },
112
+ {
113
+ emptyLineBefore: 'always',
114
+ order: 'flexible',
115
+ properties: [
116
+ 'appearance',
117
+ 'border',
118
+ 'border-collapse',
119
+ 'border-color',
120
+ 'border-image',
121
+ 'border-border-image-outset',
122
+ 'border-image-repeat',
123
+ 'border-image-slice',
124
+ 'border-image-source',
125
+ 'border-image-width',
126
+ 'border-bottom',
127
+ 'border-bottom-color',
128
+ 'border-bottom-left-radius',
129
+ 'border-bottom-right-radius',
130
+ 'border-bottom-style',
131
+ 'border-bottom-width',
132
+ 'border-left',
133
+ 'border-left-color',
134
+ 'border-left-style',
135
+ 'border-left-width',
136
+ 'border-right',
137
+ 'border-right-color',
138
+ 'border-right-style',
139
+ 'border-right-width',
140
+ 'border-top',
141
+ 'border-top-color',
142
+ 'border-top-left-radius',
143
+ 'border-top-right-radius',
144
+ 'border-top-style',
145
+ 'border-top-width',
146
+ 'border-radius',
147
+ 'border-spacing',
148
+ 'border-style',
149
+ 'border-width',
150
+ 'outline',
151
+ 'outline-color',
152
+ 'outline-offset',
153
+ 'outline-style',
154
+ 'outline-width',
155
+ 'background',
156
+ 'background-attachment',
157
+ 'background-blend-mode',
158
+ 'background-clip',
159
+ 'background-color',
160
+ 'background-image',
161
+ 'background-origin',
162
+ 'background-position',
163
+ 'background-repeat',
164
+ 'background-size',
165
+ 'box-shadow'
166
+ ]
167
+ },
168
+ {
169
+ emptyLineBefore: 'always',
170
+ order: 'flexible',
171
+ properties: [
172
+ 'font',
173
+ 'font-family',
174
+ 'font-size',
175
+ 'font-style',
176
+ 'font-variant',
177
+ 'font-weight',
178
+ 'color',
179
+ 'line-height',
180
+ 'text',
181
+ 'text-align',
182
+ 'text-decoration',
183
+ 'text-decoration-color',
184
+ 'text-decoration-line',
185
+ 'text-decoration-style',
186
+ 'text-indent',
187
+ 'text-justify',
188
+ 'text-orientation',
189
+ 'text-overflow',
190
+ 'text-shadow',
191
+ 'text-transform',
192
+ 'text-underline-position',
193
+ 'white-space',
194
+ 'word'
195
+ ]
196
+ },
197
+ {
198
+ emptyLineBefore: 'always',
199
+ order: 'flexible',
200
+ properties: ['opacity', 'visibility']
201
+ },
202
+ {
203
+ emptyLineBefore: 'always',
204
+ order: 'flexible',
205
+ properties: ['cursor', 'user-select', 'pointer-events']
206
+ },
207
+ {
208
+ emptyLineBefore: 'always',
209
+ order: 'flexible',
210
+ properties: [
211
+ 'transition',
212
+ 'transition-delay',
213
+ 'transition-duration',
214
+ 'transition-timing-function',
215
+ 'transition-property',
216
+ 'transform',
217
+ 'transform-origin',
218
+ 'transform-style',
219
+ 'animation',
220
+ 'animation-delay',
221
+ 'animation-direction',
222
+ 'animation-duration',
223
+ 'animation-fill-mode',
224
+ 'animation-iteration-count',
225
+ 'animation-name',
226
+ 'animation-play-state',
227
+ 'animation-timing-function'
228
+ ]
229
+ }
230
+ ]
231
+ }
232
+ };
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ rules: {
3
+ 'color-named': 'never',
4
+ 'max-nesting-depth': 3,
5
+ 'media-query-list-comma-newline-after': 'always-multi-line',
6
+ 'selector-max-compound-selectors': 5,
7
+ 'selector-max-id': 0
8
+ }
9
+ };