@flint.fyi/css 0.1.0 → 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/dist/index.mjs +40 -0
- package/package.json +7 -6
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/lib/plugin.js +0 -10
- package/lib/ruleCreator.d.ts +0 -2
- package/lib/ruleCreator.js +0 -9
- package/lib/rules/hexColorValidity.d.ts +0 -9
- package/lib/rules/hexColorValidity.js +0 -27
- /package/{lib/plugin.d.ts → dist/index.d.mts} +0 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RuleCreator, createPlugin } from "@flint.fyi/core";
|
|
2
|
+
import { cssLanguage, getCssNodeRange } from "@flint.fyi/css-language";
|
|
3
|
+
//#region src/ruleCreator.ts
|
|
4
|
+
const ruleCreator = new RuleCreator({
|
|
5
|
+
docs: (ruleId) => `https://flint.fyi/rules/css/${ruleId.toLowerCase()}`,
|
|
6
|
+
pluginId: "css",
|
|
7
|
+
presets: ["logical"]
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/rules/hexColorValidity.ts
|
|
11
|
+
const validityTester = /^(?:[0-9a-f]{3,4}){1,2}$/i;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/plugin.ts
|
|
14
|
+
const css = createPlugin({
|
|
15
|
+
files: { all: ["**/*.css"] },
|
|
16
|
+
name: "CSS",
|
|
17
|
+
rules: [ruleCreator.createRule(cssLanguage, {
|
|
18
|
+
about: {
|
|
19
|
+
description: "Reports hex colors with invalid values.",
|
|
20
|
+
id: "hexColorValidity",
|
|
21
|
+
presets: ["logical"]
|
|
22
|
+
},
|
|
23
|
+
messages: { invalid: {
|
|
24
|
+
primary: "The hex value `{{ value }}` is invalid.",
|
|
25
|
+
secondary: ["Valid CSS hex colors must have 3, 4, 6, or 8 digits or letters in `a-f` after the `#`.", "This value does not match that criteria."],
|
|
26
|
+
suggestions: ["Fix the value to be a valid CSS hex color."]
|
|
27
|
+
} },
|
|
28
|
+
setup(context) {
|
|
29
|
+
return { visitors: { Hash: (node) => {
|
|
30
|
+
if (!validityTester.test(node.value)) context.report({
|
|
31
|
+
data: { value: node.value },
|
|
32
|
+
message: "invalid",
|
|
33
|
+
range: getCssNodeRange(node)
|
|
34
|
+
});
|
|
35
|
+
} } };
|
|
36
|
+
}
|
|
37
|
+
})]
|
|
38
|
+
});
|
|
39
|
+
//#endregion
|
|
40
|
+
export { css };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flint.fyi/css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "[Experimental] A Flint plugin for CSS code.",
|
|
5
5
|
"homepage": "https://flint.fyi/rules/css",
|
|
6
6
|
"repository": {
|
|
@@ -16,20 +16,21 @@
|
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
19
|
-
".": "./
|
|
19
|
+
".": "./dist/index.mjs"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"
|
|
22
|
+
"dist/"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"typescript": "^6.0.0",
|
|
26
|
-
"@flint.fyi/
|
|
27
|
-
"@flint.fyi/
|
|
26
|
+
"@flint.fyi/core": "^0.24.0",
|
|
27
|
+
"@flint.fyi/css-language": "^0.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"tsdown": "0.22.3",
|
|
31
31
|
"vitest": "4.1.0",
|
|
32
|
-
"@flint.fyi/
|
|
32
|
+
"@flint.fyi/build": "^0.1.0",
|
|
33
|
+
"@flint.fyi/rule-tester": "^0.17.0"
|
|
33
34
|
},
|
|
34
35
|
"engines": {
|
|
35
36
|
"node": ">=24.0.0"
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
package/lib/plugin.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import hexColorValidity_default from "./rules/hexColorValidity.js";
|
|
2
|
-
import { createPlugin } from "@flint.fyi/core";
|
|
3
|
-
//#region src/plugin.ts
|
|
4
|
-
const css = createPlugin({
|
|
5
|
-
files: { all: ["**/*.css"] },
|
|
6
|
-
name: "CSS",
|
|
7
|
-
rules: [hexColorValidity_default]
|
|
8
|
-
});
|
|
9
|
-
//#endregion
|
|
10
|
-
export { css };
|
package/lib/ruleCreator.d.ts
DELETED
package/lib/ruleCreator.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { RuleCreator } from "@flint.fyi/core";
|
|
2
|
-
//#region src/ruleCreator.ts
|
|
3
|
-
const ruleCreator = new RuleCreator({
|
|
4
|
-
docs: (ruleId) => `https://flint.fyi/rules/css/${ruleId.toLowerCase()}`,
|
|
5
|
-
pluginId: "css",
|
|
6
|
-
presets: ["logical"]
|
|
7
|
-
});
|
|
8
|
-
//#endregion
|
|
9
|
-
export { ruleCreator };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
-
readonly description: "Reports hex colors with invalid values.";
|
|
3
|
-
readonly id: "hexColorValidity";
|
|
4
|
-
readonly presets: readonly ["logical"];
|
|
5
|
-
} & {
|
|
6
|
-
readonly pluginId: string;
|
|
7
|
-
readonly url: string;
|
|
8
|
-
}, "invalid", undefined>;
|
|
9
|
-
export default _default;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ruleCreator } from "../ruleCreator.js";
|
|
2
|
-
import { cssLanguage, getCssNodeRange } from "@flint.fyi/css-language";
|
|
3
|
-
//#region src/rules/hexColorValidity.ts
|
|
4
|
-
const validityTester = /^(?:[0-9a-f]{3,4}){1,2}$/i;
|
|
5
|
-
var hexColorValidity_default = ruleCreator.createRule(cssLanguage, {
|
|
6
|
-
about: {
|
|
7
|
-
description: "Reports hex colors with invalid values.",
|
|
8
|
-
id: "hexColorValidity",
|
|
9
|
-
presets: ["logical"]
|
|
10
|
-
},
|
|
11
|
-
messages: { invalid: {
|
|
12
|
-
primary: "The hex value `{{ value }}` is invalid.",
|
|
13
|
-
secondary: ["Valid CSS hex colors must have 3, 4, 6, or 8 digits or letters in `a-f` after the `#`.", "This value does not match that criteria."],
|
|
14
|
-
suggestions: ["Fix the value to be a valid CSS hex color."]
|
|
15
|
-
} },
|
|
16
|
-
setup(context) {
|
|
17
|
-
return { visitors: { Hash: (node) => {
|
|
18
|
-
if (!validityTester.test(node.value)) context.report({
|
|
19
|
-
data: { value: node.value },
|
|
20
|
-
message: "invalid",
|
|
21
|
-
range: getCssNodeRange(node)
|
|
22
|
-
});
|
|
23
|
-
} } };
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
//#endregion
|
|
27
|
-
export { hexColorValidity_default as default };
|
|
File without changes
|