codelaw-rules-scss 0.3.0__py3-none-any.whl
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.
- codelaw_rules_scss/LICENSE +23 -0
- codelaw_rules_scss/NOTICE +19 -0
- codelaw_rules_scss/README.md +57 -0
- codelaw_rules_scss/codelaw-pack.toml +6 -0
- codelaw_rules_scss/corpus.toml +19 -0
- codelaw_rules_scss/data/scss/at-rules.json +68 -0
- codelaw_rules_scss/data/scss/functions.json +219 -0
- codelaw_rules_scss/presets/scss/recommended.toml +10 -0
- codelaw_rules_scss/presets/scss/strict.toml +12 -0
- codelaw_rules_scss/rules/scss/at-extend-no-missing-placeholder.cases.md +49 -0
- codelaw_rules_scss/rules/scss/at-extend-no-missing-placeholder.md +51 -0
- codelaw_rules_scss/rules/scss/at-if-no-null.cases.md +105 -0
- codelaw_rules_scss/rules/scss/at-if-no-null.md +41 -0
- codelaw_rules_scss/rules/scss/at-mixin-pattern.cases.md +25 -0
- codelaw_rules_scss/rules/scss/at-mixin-pattern.md +49 -0
- codelaw_rules_scss/rules/scss/at-rule-no-unknown.cases.md +40 -0
- codelaw_rules_scss/rules/scss/at-rule-no-unknown.md +49 -0
- codelaw_rules_scss/rules/scss/dollar-variable-pattern.cases.md +32 -0
- codelaw_rules_scss/rules/scss/dollar-variable-pattern.md +45 -0
- codelaw_rules_scss/rules/scss/double-slash-comment-empty.cases.md +57 -0
- codelaw_rules_scss/rules/scss/double-slash-comment-empty.md +41 -0
- codelaw_rules_scss/rules/scss/function-no-unknown.cases.md +69 -0
- codelaw_rules_scss/rules/scss/function-no-unknown.md +51 -0
- codelaw_rules_scss/rules/scss/load-no-partial-leading-underscore.cases.md +46 -0
- codelaw_rules_scss/rules/scss/load-no-partial-leading-underscore.md +37 -0
- codelaw_rules_scss/rules/scss/max-nesting-depth.cases.md +53 -0
- codelaw_rules_scss/rules/scss/max-nesting-depth.md +63 -0
- codelaw_rules_scss/rules/scss/no-duplicate-dollar-variables.cases.md +49 -0
- codelaw_rules_scss/rules/scss/no-duplicate-dollar-variables.md +45 -0
- codelaw_rules_scss/rules/scss/no-duplicate-mixins.cases.md +33 -0
- codelaw_rules_scss/rules/scss/no-duplicate-mixins.md +52 -0
- codelaw_rules_scss/rules/scss/no-global-function-names.cases.md +125 -0
- codelaw_rules_scss/rules/scss/no-global-function-names.md +43 -0
- codelaw_rules_scss/rules/scss/no-import.cases.md +55 -0
- codelaw_rules_scss/rules/scss/no-import.md +45 -0
- codelaw_rules_scss/rules/scss/no-slash-division.cases.md +85 -0
- codelaw_rules_scss/rules/scss/no-slash-division.md +48 -0
- codelaw_rules_scss/rules/scss/percent-placeholder-pattern.cases.md +25 -0
- codelaw_rules_scss/rules/scss/percent-placeholder-pattern.md +49 -0
- codelaw_rules_scss-0.3.0.dist-info/METADATA +67 -0
- codelaw_rules_scss-0.3.0.dist-info/RECORD +43 -0
- codelaw_rules_scss-0.3.0.dist-info/WHEEL +4 -0
- codelaw_rules_scss-0.3.0.dist-info/licenses/LICENSE +23 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Arpit Arya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
SPDX-License-Identifier: MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@codelaw/rules-scss / codelaw-rules-scss
|
|
2
|
+
|
|
3
|
+
The rules are reimplementations written for codelaw. Their `ported_from:`
|
|
4
|
+
fields name the stylelint-scss rules (https://github.com/stylelint-scss/stylelint-scss,
|
|
5
|
+
MIT License, Copyright (c) 2015 - present stylelint-scss contributors) and
|
|
6
|
+
the stylelint rule (https://stylelint.io, MIT License) whose documented
|
|
7
|
+
behaviour they reproduce; no stylelint-scss or stylelint code or
|
|
8
|
+
documentation text is included. `scss/no-import`, `scss/no-slash-division`
|
|
9
|
+
and `scss/double-slash-comment-empty` follow Dart Sass's deprecations
|
|
10
|
+
(https://sass-lang.com/documentation/breaking-changes/) and have no source
|
|
11
|
+
rule.
|
|
12
|
+
|
|
13
|
+
The data tables in data/scss/ are lists of names:
|
|
14
|
+
|
|
15
|
+
- at-rules.json: the CSS at-rule names of codelaw-rules-css's table
|
|
16
|
+
(extracted from stylelint 17.16.0's reference lists, MIT License) and
|
|
17
|
+
Sass's own at-rule names.
|
|
18
|
+
- functions.json: CSS function names (from the CSS specifications) and the
|
|
19
|
+
names of Dart Sass's built-in functions (https://sass-lang.com/documentation/modules/).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @codelaw/rules-scss · codelaw-rules-scss
|
|
2
|
+
|
|
3
|
+
codelaw's rules for SCSS (Sass's `.scss` syntax) — one of the first-party rule
|
|
4
|
+
packs ([SR-RULE-PACKS](../../records/0101_rule-packs.md)). The same files ship on
|
|
5
|
+
npm as `@codelaw/rules-scss` and on PyPI as `codelaw-rules-scss`.
|
|
6
|
+
|
|
7
|
+
SCSS is a CSS dialect under [L3](../../records/0005_LAW-3-languages.md) (amended
|
|
8
|
+
2026-10-26): `codelaw format` and `codelaw check` read `.scss` files with their
|
|
9
|
+
own grammar, and **the `css/*` rules of `@codelaw/rules-css` also run on SCSS**
|
|
10
|
+
where they declare `scss` — install both packs in an SCSS project. The indented
|
|
11
|
+
`.sass` syntax and Less are out of scope.
|
|
12
|
+
|
|
13
|
+
```toml
|
|
14
|
+
# codelaw.toml
|
|
15
|
+
extends = ["codelaw:css/recommended", "codelaw:scss/recommended"]
|
|
16
|
+
preview = true # every rule is `preview` until a corpus run promotes it
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Presets
|
|
20
|
+
|
|
21
|
+
<!-- docs-sync:presets -->
|
|
22
|
+
|
|
23
|
+
| preset | rules | ported from |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `scss/recommended` | 7 | correctness: at-rule-no-unknown, duplicate definitions, `@extend` placeholders, null tests, empty comments, partial names |
|
|
26
|
+
| `scss/strict` | 15 | the additions to `scss/recommended` (it extends it): Dart Sass's module migrations (no `@import`, no global function names, no slash division), unknown functions, naming patterns and a nesting limit |
|
|
27
|
+
|
|
28
|
+
<!-- /docs-sync:presets -->
|
|
29
|
+
|
|
30
|
+
`scss/no-import` is in `strict`, not `recommended`: a codebase that still uses `@import` moves to
|
|
31
|
+
`@use` on its own schedule.
|
|
32
|
+
|
|
33
|
+
## Rules
|
|
34
|
+
|
|
35
|
+
<!-- docs-sync:rules -->
|
|
36
|
+
|
|
37
|
+
| rule | fix | flags |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| `scss/at-extend-no-missing-placeholder` | manual | `@extend .class` instead of a `%placeholder` |
|
|
40
|
+
| `scss/at-if-no-null` | auto | `@if $x != null` (fixed to `$x`) and `@if $x == null` (fixed to `not $x`) |
|
|
41
|
+
| `scss/at-mixin-pattern` | manual | mixin names outside the pattern (kebab-case) |
|
|
42
|
+
| `scss/at-rule-no-unknown` | manual | at-rules neither CSS nor Sass defines |
|
|
43
|
+
| `scss/dollar-variable-pattern` | manual | `$variable` names outside the pattern (kebab-case) |
|
|
44
|
+
| `scss/double-slash-comment-empty` | auto | an empty `//` comment |
|
|
45
|
+
| `scss/function-no-unknown` | manual | functions that are not CSS, Sass built-ins or the file's own |
|
|
46
|
+
| `scss/load-no-partial-leading-underscore` | auto | `@use "_partial"` |
|
|
47
|
+
| `scss/max-nesting-depth` | manual | style rules nested deeper than `max` (3) |
|
|
48
|
+
| `scss/no-duplicate-dollar-variables` | manual | a `$variable` declared twice in one scope |
|
|
49
|
+
| `scss/no-duplicate-mixins` | manual | a mixin defined twice in one scope |
|
|
50
|
+
| `scss/no-global-function-names` | auto | `map-get()` and the other built-ins that moved into modules |
|
|
51
|
+
| `scss/no-import` | suggest | `@import` of a Sass file |
|
|
52
|
+
| `scss/no-slash-division` | suggest | `/` as division |
|
|
53
|
+
| `scss/percent-placeholder-pattern` | manual | `%placeholder` names outside the pattern (kebab-case) |
|
|
54
|
+
|
|
55
|
+
<!-- /docs-sync:rules -->
|
|
56
|
+
|
|
57
|
+
`$a+$b` is not a rule here: spacing around an operator is layout, and layout is the formatter's ([SR-FORMATTER](../../records/0105_formatter.md) decision 3) — `codelaw format` spaces it.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
name = "@codelaw/rules-scss"
|
|
2
|
+
version = "0.3.0"
|
|
3
|
+
min_codelaw = "0.1.0"
|
|
4
|
+
languages = ["scss"]
|
|
5
|
+
presets = ["scss/recommended", "scss/strict"]
|
|
6
|
+
description = "codelaw's rules for SCSS (Sass), ported from stylelint-scss, with Dart Sass's module-system migrations (SR-RULE-PACKS)"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# `codelaw test --corpus` finding counts (SR-RULE-AUTHORING decision 4).
|
|
2
|
+
# Rewrite with --update-snapshot, and review the change.
|
|
3
|
+
|
|
4
|
+
[findings]
|
|
5
|
+
"scss/at-extend-no-missing-placeholder" = 21
|
|
6
|
+
"scss/at-if-no-null" = 20
|
|
7
|
+
"scss/at-mixin-pattern" = 6
|
|
8
|
+
"scss/at-rule-no-unknown" = 0
|
|
9
|
+
"scss/dollar-variable-pattern" = 5
|
|
10
|
+
"scss/double-slash-comment-empty" = 227
|
|
11
|
+
"scss/function-no-unknown" = 96
|
|
12
|
+
"scss/load-no-partial-leading-underscore" = 0
|
|
13
|
+
"scss/max-nesting-depth" = 15
|
|
14
|
+
"scss/no-duplicate-dollar-variables" = 9
|
|
15
|
+
"scss/no-duplicate-mixins" = 0
|
|
16
|
+
"scss/no-global-function-names" = 191
|
|
17
|
+
"scss/no-import" = 197
|
|
18
|
+
"scss/no-slash-division" = 10
|
|
19
|
+
"scss/percent-placeholder-pattern" = 1
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"known": [
|
|
3
|
+
"annotation",
|
|
4
|
+
"apply",
|
|
5
|
+
"at-root",
|
|
6
|
+
"bottom-center",
|
|
7
|
+
"bottom-left",
|
|
8
|
+
"bottom-left-corner",
|
|
9
|
+
"bottom-right",
|
|
10
|
+
"bottom-right-corner",
|
|
11
|
+
"character-variant",
|
|
12
|
+
"container",
|
|
13
|
+
"content",
|
|
14
|
+
"counter-style",
|
|
15
|
+
"custom-media",
|
|
16
|
+
"custom-selector",
|
|
17
|
+
"debug",
|
|
18
|
+
"document",
|
|
19
|
+
"each",
|
|
20
|
+
"else",
|
|
21
|
+
"error",
|
|
22
|
+
"extend",
|
|
23
|
+
"font-face",
|
|
24
|
+
"font-feature-values",
|
|
25
|
+
"font-palette-values",
|
|
26
|
+
"for",
|
|
27
|
+
"forward",
|
|
28
|
+
"function",
|
|
29
|
+
"historical-forms",
|
|
30
|
+
"if",
|
|
31
|
+
"import",
|
|
32
|
+
"include",
|
|
33
|
+
"keyframes",
|
|
34
|
+
"layer",
|
|
35
|
+
"left-bottom",
|
|
36
|
+
"left-middle",
|
|
37
|
+
"left-top",
|
|
38
|
+
"media",
|
|
39
|
+
"mixin",
|
|
40
|
+
"namespace",
|
|
41
|
+
"nest",
|
|
42
|
+
"ornaments",
|
|
43
|
+
"page",
|
|
44
|
+
"position-try",
|
|
45
|
+
"property",
|
|
46
|
+
"return",
|
|
47
|
+
"right-bottom",
|
|
48
|
+
"right-middle",
|
|
49
|
+
"right-top",
|
|
50
|
+
"scope",
|
|
51
|
+
"scroll-timeline",
|
|
52
|
+
"starting-style",
|
|
53
|
+
"styleset",
|
|
54
|
+
"stylistic",
|
|
55
|
+
"supports",
|
|
56
|
+
"swash",
|
|
57
|
+
"top-center",
|
|
58
|
+
"top-left",
|
|
59
|
+
"top-left-corner",
|
|
60
|
+
"top-right",
|
|
61
|
+
"top-right-corner",
|
|
62
|
+
"use",
|
|
63
|
+
"view-transition",
|
|
64
|
+
"viewport",
|
|
65
|
+
"warn",
|
|
66
|
+
"while"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
{
|
|
2
|
+
"css": [
|
|
3
|
+
"abs",
|
|
4
|
+
"acos",
|
|
5
|
+
"alpha",
|
|
6
|
+
"anchor",
|
|
7
|
+
"anchor-name",
|
|
8
|
+
"anchor-size",
|
|
9
|
+
"asin",
|
|
10
|
+
"atan",
|
|
11
|
+
"atan2",
|
|
12
|
+
"attr",
|
|
13
|
+
"blur",
|
|
14
|
+
"brightness",
|
|
15
|
+
"calc",
|
|
16
|
+
"calc-size",
|
|
17
|
+
"circle",
|
|
18
|
+
"clamp",
|
|
19
|
+
"color",
|
|
20
|
+
"color-contrast",
|
|
21
|
+
"color-mix",
|
|
22
|
+
"conic-gradient",
|
|
23
|
+
"contrast",
|
|
24
|
+
"contrast-color",
|
|
25
|
+
"cos",
|
|
26
|
+
"counter",
|
|
27
|
+
"counters",
|
|
28
|
+
"cross-fade",
|
|
29
|
+
"cubic-bezier",
|
|
30
|
+
"device-cmyk",
|
|
31
|
+
"drop-shadow",
|
|
32
|
+
"element",
|
|
33
|
+
"ellipse",
|
|
34
|
+
"env",
|
|
35
|
+
"exp",
|
|
36
|
+
"expression",
|
|
37
|
+
"fit-content",
|
|
38
|
+
"format",
|
|
39
|
+
"from-font",
|
|
40
|
+
"grayscale",
|
|
41
|
+
"hsl",
|
|
42
|
+
"hsla",
|
|
43
|
+
"hue-rotate",
|
|
44
|
+
"hwb",
|
|
45
|
+
"hypot",
|
|
46
|
+
"if",
|
|
47
|
+
"image",
|
|
48
|
+
"image-set",
|
|
49
|
+
"inset",
|
|
50
|
+
"invert",
|
|
51
|
+
"lab",
|
|
52
|
+
"layer",
|
|
53
|
+
"lch",
|
|
54
|
+
"leader",
|
|
55
|
+
"light-dark",
|
|
56
|
+
"linear",
|
|
57
|
+
"linear-gradient",
|
|
58
|
+
"local",
|
|
59
|
+
"log",
|
|
60
|
+
"matrix",
|
|
61
|
+
"matrix3d",
|
|
62
|
+
"max",
|
|
63
|
+
"min",
|
|
64
|
+
"minmax",
|
|
65
|
+
"mod",
|
|
66
|
+
"oklab",
|
|
67
|
+
"oklch",
|
|
68
|
+
"opacity",
|
|
69
|
+
"paint",
|
|
70
|
+
"path",
|
|
71
|
+
"perspective",
|
|
72
|
+
"polygon",
|
|
73
|
+
"pow",
|
|
74
|
+
"progid",
|
|
75
|
+
"radial-gradient",
|
|
76
|
+
"ray",
|
|
77
|
+
"rect",
|
|
78
|
+
"rem",
|
|
79
|
+
"repeat",
|
|
80
|
+
"repeating-conic-gradient",
|
|
81
|
+
"repeating-linear-gradient",
|
|
82
|
+
"repeating-radial-gradient",
|
|
83
|
+
"rgb",
|
|
84
|
+
"rgba",
|
|
85
|
+
"rotate",
|
|
86
|
+
"rotate3d",
|
|
87
|
+
"rotatex",
|
|
88
|
+
"rotatey",
|
|
89
|
+
"rotatez",
|
|
90
|
+
"round",
|
|
91
|
+
"running",
|
|
92
|
+
"saturate",
|
|
93
|
+
"scale",
|
|
94
|
+
"scale3d",
|
|
95
|
+
"scalex",
|
|
96
|
+
"scaley",
|
|
97
|
+
"scalez",
|
|
98
|
+
"scroll",
|
|
99
|
+
"selector",
|
|
100
|
+
"sepia",
|
|
101
|
+
"shape",
|
|
102
|
+
"sign",
|
|
103
|
+
"sin",
|
|
104
|
+
"skew",
|
|
105
|
+
"skewx",
|
|
106
|
+
"skewy",
|
|
107
|
+
"sqrt",
|
|
108
|
+
"src",
|
|
109
|
+
"steps",
|
|
110
|
+
"string",
|
|
111
|
+
"style",
|
|
112
|
+
"symbols",
|
|
113
|
+
"tan",
|
|
114
|
+
"target-counter",
|
|
115
|
+
"target-counters",
|
|
116
|
+
"target-text",
|
|
117
|
+
"tech",
|
|
118
|
+
"translate",
|
|
119
|
+
"translate3d",
|
|
120
|
+
"translatex",
|
|
121
|
+
"translatey",
|
|
122
|
+
"translatez",
|
|
123
|
+
"url",
|
|
124
|
+
"var",
|
|
125
|
+
"view",
|
|
126
|
+
"xywh"
|
|
127
|
+
],
|
|
128
|
+
"sass": [
|
|
129
|
+
"abs",
|
|
130
|
+
"adjust-color",
|
|
131
|
+
"adjust-hue",
|
|
132
|
+
"alpha",
|
|
133
|
+
"and",
|
|
134
|
+
"append",
|
|
135
|
+
"blue",
|
|
136
|
+
"call",
|
|
137
|
+
"ceil",
|
|
138
|
+
"change-color",
|
|
139
|
+
"comparable",
|
|
140
|
+
"complement",
|
|
141
|
+
"content-exists",
|
|
142
|
+
"darken",
|
|
143
|
+
"desaturate",
|
|
144
|
+
"fade",
|
|
145
|
+
"fade-in",
|
|
146
|
+
"fade-out",
|
|
147
|
+
"feature-exists",
|
|
148
|
+
"floor",
|
|
149
|
+
"function-exists",
|
|
150
|
+
"get-function",
|
|
151
|
+
"global-variable-exists",
|
|
152
|
+
"grayscale",
|
|
153
|
+
"green",
|
|
154
|
+
"hsl",
|
|
155
|
+
"hsla",
|
|
156
|
+
"hue",
|
|
157
|
+
"ie-hex-str",
|
|
158
|
+
"if",
|
|
159
|
+
"index",
|
|
160
|
+
"inspect",
|
|
161
|
+
"invert",
|
|
162
|
+
"is-bracketed",
|
|
163
|
+
"is-superselector",
|
|
164
|
+
"join",
|
|
165
|
+
"keywords",
|
|
166
|
+
"length",
|
|
167
|
+
"lighten",
|
|
168
|
+
"lightness",
|
|
169
|
+
"list-separator",
|
|
170
|
+
"map-get",
|
|
171
|
+
"map-has-key",
|
|
172
|
+
"map-keys",
|
|
173
|
+
"map-merge",
|
|
174
|
+
"map-remove",
|
|
175
|
+
"map-values",
|
|
176
|
+
"max",
|
|
177
|
+
"min",
|
|
178
|
+
"mix",
|
|
179
|
+
"mixin-exists",
|
|
180
|
+
"not",
|
|
181
|
+
"nth",
|
|
182
|
+
"opacify",
|
|
183
|
+
"opacity",
|
|
184
|
+
"or",
|
|
185
|
+
"percentage",
|
|
186
|
+
"quote",
|
|
187
|
+
"random",
|
|
188
|
+
"red",
|
|
189
|
+
"rgb",
|
|
190
|
+
"rgba",
|
|
191
|
+
"round",
|
|
192
|
+
"saturate",
|
|
193
|
+
"saturation",
|
|
194
|
+
"scale-color",
|
|
195
|
+
"selector-append",
|
|
196
|
+
"selector-extend",
|
|
197
|
+
"selector-nest",
|
|
198
|
+
"selector-parse",
|
|
199
|
+
"selector-replace",
|
|
200
|
+
"selector-unify",
|
|
201
|
+
"set-nth",
|
|
202
|
+
"simple-selectors",
|
|
203
|
+
"sqrt",
|
|
204
|
+
"str-index",
|
|
205
|
+
"str-insert",
|
|
206
|
+
"str-length",
|
|
207
|
+
"str-slice",
|
|
208
|
+
"to-lower-case",
|
|
209
|
+
"to-upper-case",
|
|
210
|
+
"transparentize",
|
|
211
|
+
"type-of",
|
|
212
|
+
"unique-id",
|
|
213
|
+
"unit",
|
|
214
|
+
"unitless",
|
|
215
|
+
"unquote",
|
|
216
|
+
"variable-exists",
|
|
217
|
+
"zip"
|
|
218
|
+
]
|
|
219
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
description = "SCSS correctness: unknown at-rules and functions' neighbours, duplicate definitions, placeholders, null tests"
|
|
2
|
+
|
|
3
|
+
[rules]
|
|
4
|
+
"scss/at-extend-no-missing-placeholder" = "error"
|
|
5
|
+
"scss/at-if-no-null" = "error"
|
|
6
|
+
"scss/at-rule-no-unknown" = "error"
|
|
7
|
+
"scss/double-slash-comment-empty" = "error"
|
|
8
|
+
"scss/load-no-partial-leading-underscore" = "error"
|
|
9
|
+
"scss/no-duplicate-dollar-variables" = "error"
|
|
10
|
+
"scss/no-duplicate-mixins" = "error"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
extends = ["codelaw:scss/recommended"]
|
|
2
|
+
description = "scss/recommended plus Dart Sass's module-system migrations (no @import, no global functions, no slash division), unknown functions, naming patterns and a nesting limit"
|
|
3
|
+
|
|
4
|
+
[rules]
|
|
5
|
+
"scss/at-mixin-pattern" = "error"
|
|
6
|
+
"scss/dollar-variable-pattern" = "error"
|
|
7
|
+
"scss/function-no-unknown" = "error"
|
|
8
|
+
"scss/max-nesting-depth" = "error"
|
|
9
|
+
"scss/no-global-function-names" = "error"
|
|
10
|
+
"scss/no-import" = "error"
|
|
11
|
+
"scss/no-slash-division" = "error"
|
|
12
|
+
"scss/percent-placeholder-pattern" = "error"
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Cases: scss/at-extend-no-missing-placeholder
|
|
2
|
+
|
|
3
|
+
### case: a placeholder
|
|
4
|
+
|
|
5
|
+
```scss
|
|
6
|
+
.a {
|
|
7
|
+
@extend %b;
|
|
8
|
+
}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```expect
|
|
12
|
+
(none)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### case: an element
|
|
16
|
+
|
|
17
|
+
```scss
|
|
18
|
+
.a {
|
|
19
|
+
@extend a;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```expect
|
|
24
|
+
2:11 scss/at-extend-no-missing-placeholder
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### case: an optional class
|
|
28
|
+
|
|
29
|
+
```scss
|
|
30
|
+
.a {
|
|
31
|
+
@extend .b !optional;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```expect
|
|
36
|
+
2:11 scss/at-extend-no-missing-placeholder
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### case: interpolation
|
|
40
|
+
|
|
41
|
+
```scss
|
|
42
|
+
.a {
|
|
43
|
+
@extend #{$sel};
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```expect
|
|
48
|
+
(none)
|
|
49
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: scss/at-extend-no-missing-placeholder
|
|
3
|
+
title: "`@extend` targets a placeholder"
|
|
4
|
+
languages: [scss]
|
|
5
|
+
fix: manual
|
|
6
|
+
fix_reason: "turning a class into a placeholder changes the stylesheet's output"
|
|
7
|
+
stability: preview
|
|
8
|
+
ported_from: [stylelint-scss/at-extend-no-missing-placeholder]
|
|
9
|
+
since: 0.3.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
`@extend` names a `%placeholder`, not a class or an element.
|
|
13
|
+
|
|
14
|
+
**Why:** Extending a class drags every selector that mentions the class into the output, including ones far from the code at hand.
|
|
15
|
+
|
|
16
|
+
```codelaw
|
|
17
|
+
native: scss/at-extend-no-missing-placeholder
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## How to fix
|
|
21
|
+
|
|
22
|
+
1. Move the shared declarations into a `%placeholder`.
|
|
23
|
+
2. `@extend` the placeholder from each place that needs it.
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
### SCSS
|
|
28
|
+
|
|
29
|
+
#### Don't
|
|
30
|
+
|
|
31
|
+
```scss
|
|
32
|
+
.a {
|
|
33
|
+
@extend .b;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### Do
|
|
38
|
+
|
|
39
|
+
```scss
|
|
40
|
+
%b {
|
|
41
|
+
color: red;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.a {
|
|
45
|
+
@extend %b;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Differences from the source
|
|
50
|
+
|
|
51
|
+
A target with interpolation is not judged.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Cases: scss/at-if-no-null
|
|
2
|
+
|
|
3
|
+
### case: not equal
|
|
4
|
+
|
|
5
|
+
```scss
|
|
6
|
+
@if $x != null {
|
|
7
|
+
a: b;
|
|
8
|
+
}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```expect
|
|
12
|
+
1:5 scss/at-if-no-null
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```fixed
|
|
16
|
+
@if $x {
|
|
17
|
+
a: b;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### case: an else if
|
|
22
|
+
|
|
23
|
+
```scss
|
|
24
|
+
@if $a {
|
|
25
|
+
a: b;
|
|
26
|
+
} @else if $x != null {
|
|
27
|
+
c: d;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```expect
|
|
32
|
+
3:12 scss/at-if-no-null
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```fixed
|
|
36
|
+
@if $a {
|
|
37
|
+
a: b;
|
|
38
|
+
} @else if $x {
|
|
39
|
+
c: d;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### case: equal becomes not
|
|
44
|
+
|
|
45
|
+
```scss
|
|
46
|
+
@if $x == null {
|
|
47
|
+
a: b;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```expect
|
|
52
|
+
1:5 scss/at-if-no-null
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```fixed
|
|
56
|
+
@if not $x {
|
|
57
|
+
a: b;
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### case: an else if that is equal
|
|
62
|
+
|
|
63
|
+
```scss
|
|
64
|
+
@if $a {
|
|
65
|
+
a: b;
|
|
66
|
+
} @else if $x == null {
|
|
67
|
+
c: d;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```expect
|
|
72
|
+
3:12 scss/at-if-no-null
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```fixed
|
|
76
|
+
@if $a {
|
|
77
|
+
a: b;
|
|
78
|
+
} @else if not $x {
|
|
79
|
+
c: d;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### case: part of a condition is reported without a fix
|
|
84
|
+
|
|
85
|
+
```scss
|
|
86
|
+
@if $x != null and $y {
|
|
87
|
+
a: b;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```expect
|
|
92
|
+
1:5 scss/at-if-no-null
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### case: no null
|
|
96
|
+
|
|
97
|
+
```scss
|
|
98
|
+
@if $x == 1 {
|
|
99
|
+
a: b;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```expect
|
|
104
|
+
(none)
|
|
105
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: scss/at-if-no-null
|
|
3
|
+
title: "No comparing to `null` in `@if`"
|
|
4
|
+
languages: [scss]
|
|
5
|
+
fix: auto
|
|
6
|
+
stability: preview
|
|
7
|
+
ported_from: [stylelint-scss/at-if-no-null]
|
|
8
|
+
since: 0.3.0
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
`@if` tests a value directly: `@if $x`, `@if not $x`, not `@if $x != null` or `@if $x == null`.
|
|
12
|
+
|
|
13
|
+
**Why:** Every value other than `null` and `false` is truthy in Sass, so testing the value says the same thing in fewer words.
|
|
14
|
+
|
|
15
|
+
```codelaw
|
|
16
|
+
native: scss/at-if-no-null
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### SCSS
|
|
22
|
+
|
|
23
|
+
#### Don't
|
|
24
|
+
|
|
25
|
+
```scss
|
|
26
|
+
@if $x != null {
|
|
27
|
+
a: b;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### Do
|
|
32
|
+
|
|
33
|
+
```scss
|
|
34
|
+
@if $x {
|
|
35
|
+
a: b;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Differences from the source
|
|
40
|
+
|
|
41
|
+
`$x != null` is fixed to `$x` and `$x == null` to `not $x`. A comparison that is only part of a condition is reported without a fix.
|