@master/eslint-plugin-css 2.0.0-rc.8 → 2.0.0-rc.81

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.
Files changed (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +228 -7
  3. package/dist/configs/base.d.ts +6 -0
  4. package/dist/configs/base.js +5 -0
  5. package/dist/configs/legacy.d.ts +6 -0
  6. package/dist/configs/legacy.js +9 -0
  7. package/dist/configs/recommended.d.ts +6 -14
  8. package/dist/configs/recommended.js +13 -1
  9. package/dist/configs/stylesheet.d.ts +6 -0
  10. package/dist/configs/stylesheet.js +11 -0
  11. package/dist/create-rule.d.ts +12 -0
  12. package/dist/create-rule.js +5 -0
  13. package/dist/index.d.ts +16 -1
  14. package/dist/index.js +19 -1
  15. package/dist/plugin.d.ts +6 -3
  16. package/dist/plugin.js +26 -1
  17. package/dist/rules/no-conflicting-classes.d.ts +6 -0
  18. package/dist/rules/no-conflicting-classes.js +37 -0
  19. package/dist/rules/no-invalid-classes.d.ts +6 -0
  20. package/dist/rules/no-invalid-classes.js +42 -0
  21. package/dist/rules/no-unapproved-raw-values.d.ts +10 -0
  22. package/dist/rules/no-unapproved-raw-values.js +59 -0
  23. package/dist/rules/prefer-canonical-classes.d.ts +8 -0
  24. package/dist/rules/prefer-canonical-classes.js +95 -0
  25. package/dist/rules/sort-classes.d.ts +6 -0
  26. package/dist/rules/sort-classes.js +44 -0
  27. package/dist/settings-schema.d.ts +7 -0
  28. package/dist/settings-schema.js +27 -0
  29. package/dist/settings.d.ts +17 -5
  30. package/dist/settings.js +8 -1
  31. package/dist/stylesheet-parser.d.ts +31 -0
  32. package/dist/stylesheet-parser.js +33 -0
  33. package/dist/utils/define-source-visitors.d.ts +21 -0
  34. package/dist/utils/define-source-visitors.js +52 -0
  35. package/dist/utils/define-visitors.d.ts +15 -5
  36. package/dist/utils/define-visitors.js +107 -1
  37. package/dist/utils/is-same-or-child-path.d.ts +4 -0
  38. package/dist/utils/is-same-or-child-path.js +8 -0
  39. package/dist/utils/master-css.d.ts +7 -0
  40. package/dist/utils/master-css.js +6 -0
  41. package/dist/utils/report-lint-diagnostics.d.ts +20 -0
  42. package/dist/utils/report-lint-diagnostics.js +46 -0
  43. package/dist/utils/resolve-class-node.d.ts +24 -0
  44. package/dist/utils/resolve-class-node.js +85 -0
  45. package/dist/utils/resolve-compose-directive-class-nodes.d.ts +11 -0
  46. package/dist/utils/resolve-compose-directive-class-nodes.js +157 -0
  47. package/dist/utils/resolve-context.d.ts +16 -3
  48. package/dist/utils/resolve-context.js +69 -1
  49. package/dist/utils/with-visit-class-node.d.ts +8 -0
  50. package/dist/utils/with-visit-class-node.js +51 -0
  51. package/package.json +78 -1
  52. package/dist/configs/config.d.ts +0 -13
  53. package/dist/configs/config.js +0 -1
  54. package/dist/configs/config.mjs +0 -1
  55. package/dist/configs/flat.d.ts +0 -16
  56. package/dist/configs/flat.js +0 -1
  57. package/dist/configs/flat.mjs +0 -1
  58. package/dist/configs/recommended.mjs +0 -1
  59. package/dist/index.mjs +0 -1
  60. package/dist/plugin.mjs +0 -1
  61. package/dist/rules/class-collision.d.ts +0 -3
  62. package/dist/rules/class-collision.js +0 -1
  63. package/dist/rules/class-collision.mjs +0 -1
  64. package/dist/rules/class-order.d.ts +0 -3
  65. package/dist/rules/class-order.js +0 -1
  66. package/dist/rules/class-order.mjs +0 -1
  67. package/dist/rules/class-validation.d.ts +0 -3
  68. package/dist/rules/class-validation.js +0 -1
  69. package/dist/rules/class-validation.mjs +0 -1
  70. package/dist/settings.mjs +0 -1
  71. package/dist/utils/are-declarations-equal.d.ts +0 -1
  72. package/dist/utils/are-declarations-equal.js +0 -1
  73. package/dist/utils/are-declarations-equal.mjs +0 -1
  74. package/dist/utils/define-visitors.mjs +0 -1
  75. package/dist/utils/extract-classnames-from-value.d.ts +0 -6
  76. package/dist/utils/extract-classnames-from-value.js +0 -1
  77. package/dist/utils/extract-classnames-from-value.mjs +0 -1
  78. package/dist/utils/extract-range-from-node.d.ts +0 -1
  79. package/dist/utils/extract-range-from-node.js +0 -1
  80. package/dist/utils/extract-range-from-node.mjs +0 -1
  81. package/dist/utils/extract-value-from-node.d.ts +0 -1
  82. package/dist/utils/extract-value-from-node.js +0 -1
  83. package/dist/utils/extract-value-from-node.mjs +0 -1
  84. package/dist/utils/find-loc.d.ts +0 -7
  85. package/dist/utils/find-loc.js +0 -1
  86. package/dist/utils/find-loc.mjs +0 -1
  87. package/dist/utils/get-mastercss.d.ts +0 -2
  88. package/dist/utils/get-mastercss.js +0 -1
  89. package/dist/utils/get-mastercss.mjs +0 -1
  90. package/dist/utils/get-template-element-body.d.ts +0 -1
  91. package/dist/utils/get-template-element-body.js +0 -1
  92. package/dist/utils/get-template-element-body.mjs +0 -1
  93. package/dist/utils/get-template-element-prefix.d.ts +0 -1
  94. package/dist/utils/get-template-element-prefix.js +0 -1
  95. package/dist/utils/get-template-element-prefix.mjs +0 -1
  96. package/dist/utils/get-template-element-suffix.d.ts +0 -1
  97. package/dist/utils/get-template-element-suffix.js +0 -1
  98. package/dist/utils/get-template-element-suffix.mjs +0 -1
  99. package/dist/utils/parse-node-recursive.d.ts +0 -13
  100. package/dist/utils/parse-node-recursive.js +0 -1
  101. package/dist/utils/parse-node-recursive.mjs +0 -1
  102. package/dist/utils/reorder-valid-classes-action.d.ts +0 -3
  103. package/dist/utils/reorder-valid-classes-action.js +0 -1
  104. package/dist/utils/reorder-valid-classes-action.mjs +0 -1
  105. package/dist/utils/resolve-context.mjs +0 -1
  106. package/dist/utils/valid-rules-action.d.ts +0 -3
  107. package/dist/utils/valid-rules-action.js +0 -1
  108. package/dist/utils/valid-rules-action.mjs +0 -1
  109. package/dist/utils/validate-action.d.ts +0 -3
  110. package/dist/utils/validate-action.js +0 -1
  111. package/dist/utils/validate-action.mjs +0 -1
  112. package/dist/utils/workers/reorder-valid-classes.d.ts +0 -2
  113. package/dist/utils/workers/reorder-valid-classes.js +0 -1
  114. package/dist/utils/workers/reorder-valid-classes.mjs +0 -1
  115. package/dist/utils/workers/valid-rules.d.ts +0 -2
  116. package/dist/utils/workers/valid-rules.js +0 -1
  117. package/dist/utils/workers/valid-rules.mjs +0 -1
  118. package/dist/utils/workers/validate.d.ts +0 -5
  119. package/dist/utils/workers/validate.js +0 -1
  120. package/dist/utils/workers/validate.mjs +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Aoyue Design LLC.
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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -41,19 +41,240 @@
41
41
  <img alt="Follow @mastercorg" src="https://img.shields.io/static/v1?label=%20&message=twitter&color=f6f7f8&logo=twitter&style=for-the-badge">
42
42
  </picture>
43
43
  </a>
44
- <a aria-label="Github Actions" href="https://github.com/1aron/repo/actions/workflows/release.yml">
44
+ <a aria-label="Github Actions" href="https://github.com/master-co/css/actions/workflows/ci-release.yml">
45
45
  <picture>
46
- <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/github/actions/workflow/status/master-co/css/release.yml?branch=rc&label=%20&message=twitter&color=212022&logo=githubactions&style=for-the-badge">
47
- <source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/github/actions/workflow/status/master-co/css/release.yml?branch=rc&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
48
- <img alt="Github release actions" src="https://img.shields.io/github/actions/workflow/status/master-co/css/release.yml?branch=rc&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
46
+ <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/github/actions/workflow/status/master-co/css/ci-release.yml?branch=rc&label=%20&message=twitter&color=212022&logo=githubactions&style=for-the-badge">
47
+ <source media="(prefers-color-scheme: light)" srcset="https://img.shields.io/github/actions/workflow/status/master-co/css/ci-release.yml?branch=rc&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
48
+ <img alt="Github release actions" src="https://img.shields.io/github/actions/workflow/status/master-co/css/ci-release.yml?branch=rc&label=%20&message=twitter&color=f6f7f8&logo=githubactions&style=for-the-badge&logoColor=%23000">
49
49
  </picture>
50
50
  </a>
51
51
  </p>
52
52
 
53
53
  </div>
54
54
 
55
- ## Documentation
56
- Check out the official [documentation](https://rc.css.master.co/docs/code-linting).
55
+ ## Installation
56
+
57
+ ```bash
58
+ npm install -D @master/eslint-plugin-css
59
+ ```
60
+
61
+ The recommended config is also available through `@master/eslint-config-css`.
62
+
63
+ In Visual Studio Code, install the VS Code ESLint extension to surface these diagnostics and run sort-on-save. The Master CSS extension provides completion, hover, colors, highlighting, directive diagnostics, manifest diagnostics, and directive formatting; it does not duplicate class policy warnings by default.
64
+
65
+ ## Usage
66
+
67
+ Use ESLint flat configuration:
68
+
69
+ ```js
70
+ import { defineConfig } from 'eslint/config'
71
+ import css from '@master/eslint-config-css'
72
+ import htmlParser from '@angular-eslint/template-parser'
73
+ import tsParser from '@typescript-eslint/parser'
74
+
75
+ export default defineConfig([
76
+ {
77
+ files: ['**/*.html'],
78
+ languageOptions: {
79
+ parser: htmlParser
80
+ }
81
+ },
82
+ {
83
+ files: ['**/*.{ts,tsx}'],
84
+ languageOptions: {
85
+ parser: tsParser
86
+ }
87
+ },
88
+ ...css,
89
+ {
90
+ rules: {
91
+ '@master/css/no-invalid-classes': ['error', {
92
+ disallowUnknownClass: true
93
+ }]
94
+ }
95
+ }
96
+ ])
97
+ ```
98
+
99
+ ## Rules
100
+
101
+ ### `@master/css/sort-classes`
102
+
103
+ Sorts Master CSS classes into a consistent and logical order.
104
+
105
+ ```js
106
+ import { defineConfig } from 'eslint/config'
107
+
108
+ export default defineConfig([
109
+ {
110
+ rules: {
111
+ '@master/css/sort-classes': 'warn'
112
+ }
113
+ }
114
+ ])
115
+ ```
116
+
117
+ ### `@master/css/no-invalid-classes`
118
+
119
+ Disallows invalid Master CSS classes.
120
+
121
+ ```js
122
+ import { defineConfig } from 'eslint/config'
123
+
124
+ export default defineConfig([
125
+ {
126
+ rules: {
127
+ '@master/css/no-invalid-classes': 'error'
128
+ }
129
+ }
130
+ ])
131
+ ```
132
+
133
+ Set `disallowUnknownClass: true` to reject classes that do not match the active manifest:
134
+
135
+ ```js
136
+ import { defineConfig } from 'eslint/config'
137
+
138
+ export default defineConfig([
139
+ {
140
+ rules: {
141
+ '@master/css/no-invalid-classes': ['error', {
142
+ disallowUnknownClass: true
143
+ }]
144
+ }
145
+ }
146
+ ])
147
+ ```
148
+
149
+ ### `@master/css/prefer-canonical-classes`
150
+
151
+ Prefers canonical Master CSS class forms, including semantic utilities, theme tokens, property aliases, composition utilities, and condition suffix order.
152
+
153
+ ```js
154
+ import { defineConfig } from 'eslint/config'
155
+
156
+ export default defineConfig([
157
+ {
158
+ rules: {
159
+ '@master/css/prefer-canonical-classes': 'warn'
160
+ }
161
+ }
162
+ ])
163
+ ```
164
+
165
+ For example, this rule can fix `text-align:center` to `text-center`, `font:16px` to `font:md`, `margin:md` to `m:md`, `m:1rem|1.5rem` to `m:md|lg`, `fg:var(--color-red-60)` to `fg:red-60`, `w:md h:md` to `size:md`, `mt:md mb:md` to `my:md`, and `block@dark@sm` to `block@sm@dark`.
166
+
167
+ The same canonicalization applies to unquoted `@compose` class lists. In CSS, declaration-like classes are moved to native declarations and suffixes are moved to `@variant`, `@dark`, or `@light` blocks when the rewrite is safe.
168
+
169
+ Standalone CSS files are included by default when using `@master/eslint-config-css`:
170
+
171
+ ```js
172
+ import { defineConfig } from 'eslint/config'
173
+ import css from '@master/eslint-config-css'
174
+
175
+ export default defineConfig([
176
+ ...css
177
+ ])
178
+ ```
179
+
180
+ Direct plugin users can add `css.configs.stylesheet` from `@master/eslint-plugin-css` alongside the recommended config.
181
+
182
+ You can disable specific canonicalization families:
183
+
184
+ ```js
185
+ import { defineConfig } from 'eslint/config'
186
+
187
+ export default defineConfig([
188
+ {
189
+ rules: {
190
+ '@master/css/prefer-canonical-classes': ['warn', {
191
+ preferStaticUtilities: true,
192
+ preferThemeTokens: true,
193
+ preferPropertyAliases: true,
194
+ preferVariableReferences: true,
195
+ preferMultiValueTokens: true,
196
+ preferCompositionUtilities: true,
197
+ preferConditionOrder: true,
198
+ preferNativeDeclarationsInCompose: true,
199
+ preferVariantBlocksInCompose: true
200
+ }]
201
+ }
202
+ }
203
+ ])
204
+ ```
205
+
206
+ ### `@master/css/no-conflicting-classes`
207
+
208
+ Disallows classes that emit the same CSS declaration properties for the same variant.
209
+
210
+ ```js
211
+ import { defineConfig } from 'eslint/config'
212
+
213
+ export default defineConfig([
214
+ {
215
+ rules: {
216
+ '@master/css/no-conflicting-classes': 'warn'
217
+ }
218
+ }
219
+ ])
220
+ ```
221
+
222
+ When two classes conflict, the later class is treated as the effective one and the fix removes the earlier class. For partially overlapping spacing, physical inset, radius, and border width/color/style shorthands, the fix preserves the surviving declarations by splitting the earlier class, such as `mx:md ml:lg` to `mr:md ml:lg` or `b-solid bt-dashed` to `br-solid bb-solid bl-solid bt-dashed`.
223
+
224
+ ### `@master/css/no-unapproved-raw-values`
225
+
226
+ Disallows raw values in token-backed utilities unless they are explicitly allowed. This rule is opt-in team policy and is not enabled by the recommended config.
227
+
228
+ ```js
229
+ import { defineConfig } from 'eslint/config'
230
+
231
+ export default defineConfig([
232
+ {
233
+ rules: {
234
+ '@master/css/no-unapproved-raw-values': ['warn', {
235
+ allowProperties: ['width', 'height'],
236
+ allowedPatterns: ['^var\\(', '^calc\\(']
237
+ }]
238
+ }
239
+ }
240
+ ])
241
+ ```
242
+
243
+ For example, this rule reports `font:15px`, `m:17px`, and `fg:#123456` when those values are not theme tokens. It does not autofix because there may be no safe token replacement.
244
+
245
+ ## Settings
246
+
247
+ Settings live under the `@master/css` settings key:
248
+
249
+ ```js
250
+ import { defineConfig } from 'eslint/config'
251
+
252
+ export default defineConfig([
253
+ {
254
+ settings: {
255
+ '@master/css': {
256
+ classAttributes: ['class', 'className'],
257
+ classFunctions: ['clsx', 'classList.add'],
258
+ classDeclarations: ['classes'],
259
+ ignoredKeys: ['compoundVariants', 'defaultVariants'],
260
+ manifest
261
+ }
262
+ }
263
+ }
264
+ ])
265
+ ```
266
+
267
+ | Setting | Type | Description |
268
+ | --- | --- | --- |
269
+ | `classAttributes` | `string[]` | Element attributes containing class strings. |
270
+ | `classFunctions` | `string[]` | Function names whose arguments should be checked. |
271
+ | `classDeclarations` | `string[]` | Variable/member names whose declarations should be checked. |
272
+ | `ignoredKeys` | `string[]` | Object keys ignored during checking. Defaults include variant metadata keys. |
273
+ | `manifest` | `MasterCSSManifest` | Explicit compiled manifest. By default, ESLint loads the project CSS entry discovered from the current working directory. |
274
+
275
+ ## Related docs
276
+
277
+ See the [code linting guide](https://rc.css.master.co/guide/code-linting) for setup guides across frameworks and editors.
57
278
 
58
279
  ## Credits
59
- This plugin is heavily inspired by the awesome [eslint-plugin-tailwindcss](https://github.com/francoismassart/eslint-plugin-tailwindcss). We want to thank for their initial work, which served as the foundation for this project. While significant modifications have been made, the core ideas and concepts from A Plugin have been instrumental in developing this plugin.
280
+ This plugin is heavily inspired by the awesome [eslint-plugin-tailwindcss](https://github.com/francoismassart/eslint-plugin-tailwindcss). We want to thank for their initial work, which served as the foundation for this project. While significant modifications have been made, the core ideas and concepts from A Plugin have been instrumental in developing this plugin.
@@ -0,0 +1,6 @@
1
+ import { Linter } from "eslint";
2
+
3
+ //#region src/configs/base.d.ts
4
+ declare const _default: Linter.Config;
5
+ //#endregion
6
+ export { _default as default };
@@ -0,0 +1,5 @@
1
+ import plugin from "../plugin.js";
2
+ //#region src/configs/base.ts
3
+ var base_default = { plugins: { "@master/css": plugin } };
4
+ //#endregion
5
+ export { base_default as default };
@@ -0,0 +1,6 @@
1
+ import { Linter } from "eslint";
2
+
3
+ //#region src/configs/legacy.d.ts
4
+ declare const _default: Linter.LegacyConfig;
5
+ //#endregion
6
+ export { _default as default };
@@ -0,0 +1,9 @@
1
+ import recommended_default from "./recommended.js";
2
+ //#region src/configs/legacy.ts
3
+ var legacy_default = {
4
+ plugins: ["@master/css"],
5
+ rules: recommended_default.rules,
6
+ parserOptions: { ecmaFeatures: { jsx: true } }
7
+ };
8
+ //#endregion
9
+ export { legacy_default as default };
@@ -1,14 +1,6 @@
1
- declare const _default: {
2
- rules: {
3
- readonly '@master/css/class-order': "warn";
4
- readonly '@master/css/class-validation': "error";
5
- readonly '@master/css/class-collision': "warn";
6
- };
7
- parserOptions: {
8
- readonly ecmaFeatures: {
9
- readonly jsx: true;
10
- };
11
- };
12
- plugins: string[];
13
- };
14
- export default _default;
1
+ import { Linter } from "eslint";
2
+
3
+ //#region src/configs/recommended.d.ts
4
+ declare const _default: Linter.Config;
5
+ //#endregion
6
+ export { _default as default };
@@ -1 +1,13 @@
1
- var p=Object.create;var e=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var n=(o,r)=>{for(var s in r)e(o,s,{get:r[s],enumerable:!0})},i=(o,r,s,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of c(r))!l.call(o,t)&&t!==s&&e(o,t,{get:()=>r[t],enumerable:!(f=a(r,t))||f.enumerable});return o};var u=(o,r,s)=>(s=o!=null?p(g(o)):{},i(r||!o||!o.__esModule?e(s,"default",{value:o,enumerable:!0}):s,o)),d=o=>i(e({},"__esModule",{value:!0}),o);var b={};n(b,{default:()=>x});module.exports=d(b);var m=u(require("./config")),x={plugins:["@master/css"],...m.default};
1
+ import base_default from "./base.js";
2
+ //#region src/configs/recommended.ts
3
+ var recommended_default = {
4
+ ...base_default,
5
+ rules: {
6
+ "@master/css/sort-classes": "warn",
7
+ "@master/css/no-invalid-classes": "error",
8
+ "@master/css/no-conflicting-classes": "warn",
9
+ "@master/css/prefer-canonical-classes": "warn"
10
+ }
11
+ };
12
+ //#endregion
13
+ export { recommended_default as default };
@@ -0,0 +1,6 @@
1
+ import { Linter } from "eslint";
2
+
3
+ //#region src/configs/stylesheet.d.ts
4
+ declare const _default: Linter.Config;
5
+ //#endregion
6
+ export { _default as default };
@@ -0,0 +1,11 @@
1
+ import plugin from "../plugin.js";
2
+ import stylesheet_parser_default from "../stylesheet-parser.js";
3
+ //#region src/configs/stylesheet.ts
4
+ var stylesheet_default = {
5
+ files: ["**/*.{css,scss,less}"],
6
+ plugins: { "@master/css": plugin },
7
+ languageOptions: { parser: stylesheet_parser_default },
8
+ rules: { "@master/css/prefer-canonical-classes": "warn" }
9
+ };
10
+ //#endregion
11
+ export { stylesheet_default as default };
@@ -0,0 +1,12 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+
3
+ //#region src/create-rule.d.ts
4
+ declare const _default: <Options extends readonly unknown[], MessageIds extends string>({
5
+ meta,
6
+ name,
7
+ ...rule
8
+ }: Readonly<ESLintUtils.RuleWithMetaAndName<Options, MessageIds, unknown>>) => ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener> & {
9
+ name: string;
10
+ };
11
+ //#endregion
12
+ export { _default as default };
@@ -0,0 +1,5 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ //#region src/create-rule.ts
3
+ var create_rule_default = ESLintUtils.RuleCreator((name) => new URL(`/guide/code-linting#${name}`, "https://rc.css.master.co").href);
4
+ //#endregion
5
+ export { create_rule_default as default };
package/dist/index.d.ts CHANGED
@@ -1 +1,16 @@
1
- export {};
1
+ import { TSESLint } from "@typescript-eslint/utils";
2
+ import { Linter } from "eslint";
3
+ import settings from "./settings.js";
4
+
5
+ //#region src/index.d.ts
6
+ declare const masterCSSPlugin: Omit<TSESLint.Linter.Plugin, 'configs'> & {
7
+ configs: {
8
+ legacy: unknown;
9
+ base: Linter.Config;
10
+ recommended: Linter.Config;
11
+ stylesheet: Linter.Config;
12
+ };
13
+ settings: typeof settings;
14
+ };
15
+ //#endregion
16
+ export { masterCSSPlugin as default };
package/dist/index.js CHANGED
@@ -1 +1,19 @@
1
- var c=Object.create;var p=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var x=(o,m,r,f)=>{if(m&&typeof m=="object"||typeof m=="function")for(let i of l(m))!u.call(o,i)&&i!==r&&p(o,i,{get:()=>m[i],enumerable:!(f=d(m,i))||f.enumerable});return o};var t=(o,m,r)=>(r=o!=null?c(a(o)):{},x(m||!o||!o.__esModule?p(r,"default",{value:o,enumerable:!0}):r,o));var e=t(require("./plugin")),n=t(require("./settings")),g=t(require("./configs/recommended")),s=t(require("./configs/flat"));module.exports={...e.default,configs:{recommended:g.default,flat:s.default},settings:n.default};
1
+ import settings from "./settings.js";
2
+ import plugin from "./plugin.js";
3
+ import base_default from "./configs/base.js";
4
+ import recommended_default from "./configs/recommended.js";
5
+ import legacy_default from "./configs/legacy.js";
6
+ import stylesheet_default from "./configs/stylesheet.js";
7
+ //#region src/index.ts
8
+ const masterCSSPlugin = {
9
+ ...plugin,
10
+ configs: {
11
+ legacy: legacy_default,
12
+ base: base_default,
13
+ recommended: recommended_default,
14
+ stylesheet: stylesheet_default
15
+ },
16
+ settings
17
+ };
18
+ //#endregion
19
+ export { masterCSSPlugin as default };
package/dist/plugin.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- import type { ESLint } from 'eslint';
2
- declare const plugin: ESLint.Plugin;
3
- export default plugin;
1
+ import { TSESLint } from "@typescript-eslint/utils";
2
+
3
+ //#region src/plugin.d.ts
4
+ declare const plugin: TSESLint.Linter.Plugin;
5
+ //#endregion
6
+ export { plugin as default };
package/dist/plugin.js CHANGED
@@ -1 +1,26 @@
1
- var p=Object.create;var t=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var E=(s,i)=>{for(var l in i)t(s,l,{get:i[l],enumerable:!0})},n=(s,i,l,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of f(i))!g.call(s,o)&&o!==l&&t(s,o,{get:()=>i[o],enumerable:!(a=d(i,o))||a.enumerable});return s};var r=(s,i,l)=>(l=s!=null?p(u(s)):{},n(i||!s||!s.__esModule?t(l,"default",{value:s,enumerable:!0}):l,s)),L=s=>n(t({},"__esModule",{value:!0}),s);var x={};E(x,{default:()=>v});module.exports=L(x);var e=r(require("./rules/class-collision")),m=r(require("./rules/class-order")),c=r(require("./rules/class-validation"));const S={meta:{name:"@master/eslint-plugin-css"},rules:{"class-collision":e.default,"class-order":m.default,"class-validation":c.default}};var v=S;
1
+ import no_conflicting_classes_default from "./rules/no-conflicting-classes.js";
2
+ import no_invalid_classes_default from "./rules/no-invalid-classes.js";
3
+ import no_unapproved_raw_values_default from "./rules/no-unapproved-raw-values.js";
4
+ import prefer_canonical_classes_default from "./rules/prefer-canonical-classes.js";
5
+ import sort_classes_default from "./rules/sort-classes.js";
6
+ import { readFileSync } from "fs";
7
+ import { fileURLToPath } from "url";
8
+ import { dirname, resolve } from "path";
9
+ //#region src/plugin.ts
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+ const pkg = JSON.parse(readFileSync(resolve(__dirname, "..", "package.json"), "utf-8"));
12
+ const plugin = {
13
+ meta: {
14
+ name: pkg.name,
15
+ version: pkg.version
16
+ },
17
+ rules: {
18
+ "no-conflicting-classes": no_conflicting_classes_default,
19
+ "no-invalid-classes": no_invalid_classes_default,
20
+ "no-unapproved-raw-values": no_unapproved_raw_values_default,
21
+ "prefer-canonical-classes": prefer_canonical_classes_default,
22
+ "sort-classes": sort_classes_default
23
+ }
24
+ };
25
+ //#endregion
26
+ export { plugin as default };
@@ -0,0 +1,6 @@
1
+ //#region src/rules/no-conflicting-classes.d.ts
2
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"collisionClass" | "partialCollisionClass", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
3
+ name: string;
4
+ };
5
+ //#endregion
6
+ export { _default as default };
@@ -0,0 +1,37 @@
1
+ import create_rule_default from "../create-rule.js";
2
+ import defineVisitors from "../utils/define-visitors.js";
3
+ import resolveContext from "../utils/resolve-context.js";
4
+ import reportLintDiagnostics from "../utils/report-lint-diagnostics.js";
5
+ import defineSourceVisitors, { shouldUseSourceVisitors } from "../utils/define-source-visitors.js";
6
+ import { createConflictingClassesReport } from "@master/css-lint";
7
+ //#region src/rules/no-conflicting-classes.ts
8
+ var no_conflicting_classes_default = create_rule_default({
9
+ name: "no-conflicting-classes",
10
+ meta: {
11
+ type: "layout",
12
+ docs: { description: "Disallow conflicting Master CSS classes" },
13
+ messages: {
14
+ collisionClass: "{{message}}",
15
+ partialCollisionClass: "Prefer \"{{replacement}}\" over \"{{actual}}\" because \"{{conflict}}\" overrides part of it."
16
+ },
17
+ fixable: "code",
18
+ schema: []
19
+ },
20
+ defaultOptions: [],
21
+ create(context) {
22
+ const { settings, css } = resolveContext(context);
23
+ if (shouldUseSourceVisitors(context)) return defineSourceVisitors({
24
+ context,
25
+ css,
26
+ ruleId: "no-conflicting-classes"
27
+ });
28
+ return defineVisitors({
29
+ context,
30
+ settings
31
+ }, (node, resolved) => {
32
+ reportLintDiagnostics(context, node, resolved, createConflictingClassesReport(resolved.raw, css, { unescape: resolved.unescape }).diagnostics);
33
+ });
34
+ }
35
+ });
36
+ //#endregion
37
+ export { no_conflicting_classes_default as default };
@@ -0,0 +1,6 @@
1
+ //#region src/rules/no-invalid-classes.d.ts
2
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"invalidClass" | "disallowUnknownClass", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
3
+ name: string;
4
+ };
5
+ //#endregion
6
+ export { _default as default };
@@ -0,0 +1,42 @@
1
+ import create_rule_default from "../create-rule.js";
2
+ import defineVisitors from "../utils/define-visitors.js";
3
+ import resolveContext from "../utils/resolve-context.js";
4
+ import reportLintDiagnostics from "../utils/report-lint-diagnostics.js";
5
+ import defineSourceVisitors, { shouldUseSourceVisitors } from "../utils/define-source-visitors.js";
6
+ import { noInvalidClassesOptionsSchema } from "../settings-schema.js";
7
+ import { createInvalidClassesReport } from "@master/css-lint";
8
+ //#region src/rules/no-invalid-classes.ts
9
+ var no_invalid_classes_default = create_rule_default({
10
+ name: "no-invalid-classes",
11
+ meta: {
12
+ type: "problem",
13
+ docs: { description: "Disallow invalid Master CSS classes" },
14
+ messages: {
15
+ invalidClass: "{{message}}",
16
+ disallowUnknownClass: "{{message}}"
17
+ },
18
+ fixable: null,
19
+ schema: [noInvalidClassesOptionsSchema]
20
+ },
21
+ defaultOptions: [],
22
+ create: function(context) {
23
+ const { options, settings, css } = resolveContext(context);
24
+ if (shouldUseSourceVisitors(context)) return defineSourceVisitors({
25
+ context,
26
+ css,
27
+ ruleId: "no-invalid-classes",
28
+ ruleOptions: { disallowUnknownClass: options.disallowUnknownClass }
29
+ });
30
+ return defineVisitors({
31
+ context,
32
+ settings
33
+ }, (node, resolved) => {
34
+ reportLintDiagnostics(context, node, resolved, createInvalidClassesReport(resolved.raw, css, {
35
+ unescape: resolved.unescape,
36
+ disallowUnknownClass: options.disallowUnknownClass
37
+ }).diagnostics);
38
+ });
39
+ }
40
+ });
41
+ //#endregion
42
+ export { no_invalid_classes_default as default };
@@ -0,0 +1,10 @@
1
+ //#region src/rules/no-unapproved-raw-values.d.ts
2
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unapprovedRawValue", [{
3
+ allowRawValues: boolean;
4
+ allowProperties: any[];
5
+ allowedPatterns: any[];
6
+ }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
7
+ name: string;
8
+ };
9
+ //#endregion
10
+ export { _default as default };
@@ -0,0 +1,59 @@
1
+ import create_rule_default from "../create-rule.js";
2
+ import defineVisitors from "../utils/define-visitors.js";
3
+ import resolveContext from "../utils/resolve-context.js";
4
+ import reportLintDiagnostics from "../utils/report-lint-diagnostics.js";
5
+ import defineSourceVisitors, { shouldUseSourceVisitors } from "../utils/define-source-visitors.js";
6
+ import { createUnapprovedRawValueClassesReport } from "@master/css-lint";
7
+ //#region src/rules/no-unapproved-raw-values.ts
8
+ var no_unapproved_raw_values_default = create_rule_default({
9
+ name: "no-unapproved-raw-values",
10
+ meta: {
11
+ type: "suggestion",
12
+ docs: { description: "Disallow unapproved raw values in token-backed Master CSS classes" },
13
+ messages: { unapprovedRawValue: "Unexpected raw value \"{{value}}\" in \"{{className}}\". Use a token or allow it explicitly." },
14
+ fixable: null,
15
+ schema: [{
16
+ type: "object",
17
+ properties: {
18
+ allowRawValues: { type: "boolean" },
19
+ allowProperties: {
20
+ type: "array",
21
+ items: { type: "string" },
22
+ uniqueItems: true
23
+ },
24
+ allowedPatterns: {
25
+ type: "array",
26
+ items: { type: "string" },
27
+ uniqueItems: true
28
+ }
29
+ },
30
+ additionalProperties: false
31
+ }]
32
+ },
33
+ defaultOptions: [{
34
+ allowRawValues: false,
35
+ allowProperties: [],
36
+ allowedPatterns: []
37
+ }],
38
+ create(context) {
39
+ const { settings, css } = resolveContext(context);
40
+ const options = context.options[0] || {};
41
+ if (shouldUseSourceVisitors(context)) return defineSourceVisitors({
42
+ context,
43
+ css,
44
+ ruleId: "no-unapproved-raw-values",
45
+ ruleOptions: options
46
+ });
47
+ return defineVisitors({
48
+ context,
49
+ settings
50
+ }, (node, resolved) => {
51
+ reportLintDiagnostics(context, node, resolved, createUnapprovedRawValueClassesReport(resolved.raw, css, {
52
+ ...options,
53
+ unescape: resolved.unescape
54
+ }).diagnostics);
55
+ });
56
+ }
57
+ });
58
+ //#endregion
59
+ export { no_unapproved_raw_values_default as default };
@@ -0,0 +1,8 @@
1
+ import { CanonicalClassNameOptions } from "@master/css-lint";
2
+
3
+ //#region src/rules/prefer-canonical-classes.d.ts
4
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferClass", [Required<CanonicalClassNameOptions>], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
5
+ name: string;
6
+ };
7
+ //#endregion
8
+ export { _default as default };