@csstools/stylelint-at-risk 1.0.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/LICENSE.md +18 -0
- package/README.md +33 -0
- package/index.mjs +55 -0
- package/package.json +53 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT No Attribution (MIT-0)
|
|
2
|
+
|
|
3
|
+
Copyright 2023 Romain Menke, Antonio Laguna <antonio@laguna.es>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the “Software”), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# [@csstools/stylelint-at-risk](https://www.npmjs.com/package/@csstools/stylelint-at-risk)
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@csstools/stylelint-at-risk)
|
|
4
|
+
|
|
5
|
+
Warn when features are used that are at risk of being removed or changed.
|
|
6
|
+
|
|
7
|
+
- [Re-ordering of declarations after other nested rules or at-rules](https://github.com/w3c/csswg-drafts/issues/8738)
|
|
8
|
+
|
|
9
|
+
_This rule will be updated with similar warnings if and when they are needed._
|
|
10
|
+
|
|
11
|
+
## Why?
|
|
12
|
+
|
|
13
|
+
Sometimes a web feature doesn't ship quite right and should be changed.
|
|
14
|
+
While at the same time it is very important not to break existing web content.
|
|
15
|
+
This plugin aims to warn you when you are using a CSS feature that is at risk of being removed or changed.
|
|
16
|
+
|
|
17
|
+
Reducing the number of occurrences in the wild makes it more likely that the needed change can be made.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
`npm install --save-dev @csstools/stylelint-at-risk`
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
// stylelint.config.js
|
|
25
|
+
module.exports = {
|
|
26
|
+
plugins: [
|
|
27
|
+
"@csstools/stylelint-at-risk",
|
|
28
|
+
],
|
|
29
|
+
rules: {
|
|
30
|
+
"@csstools/stylelint-at-risk": true,
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
```
|
package/index.mjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import stylelint from 'stylelint';
|
|
2
|
+
|
|
3
|
+
const ruleName = '@csstools/stylelint-at-risk';
|
|
4
|
+
|
|
5
|
+
const messages = stylelint.utils.ruleMessages(ruleName, {
|
|
6
|
+
rejectedNestingDeclOrder: () => {
|
|
7
|
+
return 'Declarations after nested rules or at-rules are currently re-ordered but might not be in the future. Place all declarations before any nested rules or at-rules to prevent future compat issues.';
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
url: 'https://github.com/csstools/postcss-plugins/blob/main/plugins-stylelint/at-risk',
|
|
13
|
+
fixable: true,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const ruleFunction = (primaryOption) => {
|
|
17
|
+
return (postcssRoot, postcssResult) => {
|
|
18
|
+
if (!primaryOption) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Nested Declarations after Rules/At-Rules
|
|
23
|
+
{
|
|
24
|
+
postcssRoot.walkDecls((decl) => {
|
|
25
|
+
let prev = decl.prev();
|
|
26
|
+
|
|
27
|
+
while (prev && prev.type === 'comment') {
|
|
28
|
+
prev = prev.prev();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!prev) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (prev?.type !== 'decl') {
|
|
36
|
+
stylelint.utils.report({
|
|
37
|
+
message: messages.rejectedNestingDeclOrder(),
|
|
38
|
+
node: decl,
|
|
39
|
+
index: 0,
|
|
40
|
+
endIndex: 5,
|
|
41
|
+
result: postcssResult,
|
|
42
|
+
ruleName,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
ruleFunction.ruleName = ruleName;
|
|
52
|
+
ruleFunction.messages = messages;
|
|
53
|
+
ruleFunction.meta = meta;
|
|
54
|
+
|
|
55
|
+
export default stylelint.createPlugin(ruleName, ruleFunction);
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@csstools/stylelint-at-risk",
|
|
3
|
+
"description": "Warn on CSS features at risk of changes or removal",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"contributors": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Antonio Laguna",
|
|
8
|
+
"email": "antonio@laguna.es",
|
|
9
|
+
"url": "https://antonio.laguna.es"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "Romain Menke",
|
|
13
|
+
"email": "romainmenke@gmail.com"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT-0",
|
|
17
|
+
"funding": [
|
|
18
|
+
{
|
|
19
|
+
"type": "github",
|
|
20
|
+
"url": "https://github.com/sponsors/csstools"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "opencollective",
|
|
24
|
+
"url": "https://opencollective.com/csstools"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": "^14 || ^16 || >=18"
|
|
29
|
+
},
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "index.mjs",
|
|
32
|
+
"files": [
|
|
33
|
+
"LICENSE.md",
|
|
34
|
+
"README.md",
|
|
35
|
+
"index.mjs"
|
|
36
|
+
],
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"stylelint": "^16.2.1"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/csstools/postcss-plugins/blob/main/plugins-stylelint/at-risk#readme",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/csstools/postcss-plugins.git",
|
|
44
|
+
"directory": "plugins-stylelint/at-risk"
|
|
45
|
+
},
|
|
46
|
+
"bugs": "https://github.com/csstools/postcss-plugins/issues",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"csswg",
|
|
49
|
+
"standards",
|
|
50
|
+
"stylelint",
|
|
51
|
+
"stylelint-plugin"
|
|
52
|
+
]
|
|
53
|
+
}
|