stylelint-plugin-rhythmguard 2.0.1 → 2.1.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/CHANGELOG.md +21 -0
- package/CONTRIBUTING.md +23 -5
- package/README.md +39 -773
- package/package.json +9 -6
- package/src/audit/args.js +444 -0
- package/src/audit/baseline.js +114 -0
- package/src/audit/config.js +207 -0
- package/src/audit/contract.js +417 -0
- package/src/audit/render-github.js +39 -0
- package/src/audit/render-html.js +78 -0
- package/src/audit/render-markdown.js +216 -0
- package/src/audit/render-text.js +162 -0
- package/src/audit/render-utils.js +41 -0
- package/src/audit/report.js +115 -0
- package/src/audit/scan.js +546 -0
- package/src/audit/shared.js +108 -0
- package/src/cli/audit.js +22 -2213
- package/src/eslint/rules/tailwind-class-use-motion-scale.js +1 -0
- package/src/eslint/rules/tailwind-class-use-scale.js +1 -0
- package/src/index.js +1 -0
- package/src/rules/no-offscale-transform/index.js +1 -1
- package/src/rules/prefer-token/index.js +1 -1
- package/src/rules/use-motion-scale/index.js +1 -1
- package/src/rules/use-scale/index.js +1 -1
- package/types/__checks__/consumer.ts +70 -0
- package/types/audit.d.ts +9 -3
- package/types/index.d.ts +1 -0
|
@@ -76,6 +76,7 @@ function buildMessage(analysis, segment, lower, upper) {
|
|
|
76
76
|
module.exports = {
|
|
77
77
|
meta: {
|
|
78
78
|
docs: {
|
|
79
|
+
url: 'https://github.com/PetriLahdelma/stylelint-plugin-rhythmguard/blob/main/docs/rules/tailwind-class-use-motion-scale.md',
|
|
79
80
|
description: 'Enforce duration scale for Tailwind arbitrary motion utilities in class strings',
|
|
80
81
|
},
|
|
81
82
|
fixable: 'code',
|
|
@@ -67,6 +67,7 @@ function maybeCheckNodeText(node, sourceCode, context, analyzer, allowFix) {
|
|
|
67
67
|
module.exports = {
|
|
68
68
|
meta: {
|
|
69
69
|
docs: {
|
|
70
|
+
url: 'https://github.com/PetriLahdelma/stylelint-plugin-rhythmguard/blob/main/docs/rules/tailwind-class-use-scale.md',
|
|
70
71
|
description: 'Enforce spacing scale for Tailwind arbitrary spacing utilities in class strings',
|
|
71
72
|
},
|
|
72
73
|
fixable: 'code',
|
package/src/index.js
CHANGED
|
@@ -22,6 +22,7 @@ module.exports.configs = {
|
|
|
22
22
|
logical: require('./configs/logical'),
|
|
23
23
|
migration: require('./configs/migration'),
|
|
24
24
|
motion: require('./configs/motion'),
|
|
25
|
+
'react-tailwind': require('./configs/react-tailwind'),
|
|
25
26
|
};
|
|
26
27
|
module.exports.eslint = require('./eslint');
|
|
27
28
|
module.exports.presets = require('./presets');
|
|
@@ -269,7 +269,7 @@ ruleFunction.ruleName = ruleName;
|
|
|
269
269
|
ruleFunction.messages = messages;
|
|
270
270
|
ruleFunction.meta = {
|
|
271
271
|
fixable: true,
|
|
272
|
-
url: 'https://github.com/
|
|
272
|
+
url: 'https://github.com/PetriLahdelma/stylelint-plugin-rhythmguard/blob/main/docs/rules/no-offscale-transform.md',
|
|
273
273
|
};
|
|
274
274
|
|
|
275
275
|
module.exports = stylelint.createPlugin(ruleName, ruleFunction);
|
|
@@ -288,7 +288,7 @@ ruleFunction.ruleName = ruleName;
|
|
|
288
288
|
ruleFunction.messages = messages;
|
|
289
289
|
ruleFunction.meta = {
|
|
290
290
|
fixable: true,
|
|
291
|
-
url: 'https://github.com/
|
|
291
|
+
url: 'https://github.com/PetriLahdelma/stylelint-plugin-rhythmguard/blob/main/docs/rules/prefer-token.md',
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
module.exports = stylelint.createPlugin(ruleName, ruleFunction);
|
|
@@ -236,7 +236,7 @@ ruleFunction.ruleName = ruleName;
|
|
|
236
236
|
ruleFunction.messages = messages;
|
|
237
237
|
ruleFunction.meta = {
|
|
238
238
|
fixable: true,
|
|
239
|
-
url: 'https://github.com/
|
|
239
|
+
url: 'https://github.com/PetriLahdelma/stylelint-plugin-rhythmguard/blob/main/docs/rules/use-motion-scale.md',
|
|
240
240
|
};
|
|
241
241
|
|
|
242
242
|
module.exports = stylelint.createPlugin(ruleName, ruleFunction);
|
|
@@ -332,7 +332,7 @@ ruleFunction.ruleName = ruleName;
|
|
|
332
332
|
ruleFunction.messages = messages;
|
|
333
333
|
ruleFunction.meta = {
|
|
334
334
|
fixable: true,
|
|
335
|
-
url: 'https://github.com/
|
|
335
|
+
url: 'https://github.com/PetriLahdelma/stylelint-plugin-rhythmguard/blob/main/docs/rules/use-scale.md',
|
|
336
336
|
};
|
|
337
337
|
|
|
338
338
|
module.exports = stylelint.createPlugin(ruleName, ruleFunction);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-time consumer of the public declarations.
|
|
3
|
+
* `npm run typecheck` fails if any published export or type drifts.
|
|
4
|
+
* Nothing here runs; it only has to type-check.
|
|
5
|
+
*/
|
|
6
|
+
import plugin, { audit, configs, eslint, presets, rules } from 'stylelint-plugin-rhythmguard';
|
|
7
|
+
import type {
|
|
8
|
+
AuditContractReport,
|
|
9
|
+
AuditReport,
|
|
10
|
+
RhythmguardRuleOptions,
|
|
11
|
+
RhythmguardStylelintConfig,
|
|
12
|
+
} from 'stylelint-plugin-rhythmguard';
|
|
13
|
+
import { createAuditReport, toAuditContractReport } from 'stylelint-plugin-rhythmguard/audit';
|
|
14
|
+
import eslintPlugin from 'stylelint-plugin-rhythmguard/eslint';
|
|
15
|
+
import { getScalePreset, listScalePresetNames } from 'stylelint-plugin-rhythmguard/presets';
|
|
16
|
+
import recommended from 'stylelint-plugin-rhythmguard/configs/recommended';
|
|
17
|
+
import reactTailwind from 'stylelint-plugin-rhythmguard/configs/react-tailwind';
|
|
18
|
+
import useScale, { ruleName as useScaleName } from 'stylelint-plugin-rhythmguard/rules/use-scale';
|
|
19
|
+
|
|
20
|
+
const pluginConfigs: readonly RhythmguardStylelintConfig[] = [
|
|
21
|
+
plugin.configs.recommended,
|
|
22
|
+
plugin.configs.strict,
|
|
23
|
+
plugin.configs.tailwind,
|
|
24
|
+
plugin.configs.expanded,
|
|
25
|
+
plugin.configs.logical,
|
|
26
|
+
plugin.configs.migration,
|
|
27
|
+
plugin.configs.motion,
|
|
28
|
+
plugin.configs['react-tailwind'],
|
|
29
|
+
configs.recommended,
|
|
30
|
+
recommended,
|
|
31
|
+
reactTailwind,
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const ruleOptions: RhythmguardRuleOptions = {
|
|
35
|
+
preset: 'rhythmic-4',
|
|
36
|
+
scale: [0, 4, 8, 12, 16],
|
|
37
|
+
tokenMap: { '4px': 'var(--space-1)' },
|
|
38
|
+
tokenMapFromCssCustomProperties: true,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const useScaleRule = rules['rhythmguard/use-scale'];
|
|
42
|
+
const fixable: boolean | undefined = useScaleRule.meta.fixable;
|
|
43
|
+
const docUrl: string | undefined = useScale.meta.url;
|
|
44
|
+
const name: string = useScaleName;
|
|
45
|
+
|
|
46
|
+
const presetNames: string[] = listScalePresetNames();
|
|
47
|
+
const preset = getScalePreset('rhythmic-4');
|
|
48
|
+
const presetsAgain: string[] = presets.listScalePresetNames();
|
|
49
|
+
|
|
50
|
+
const eslintRule = eslint.rules['tailwind-class-use-scale'];
|
|
51
|
+
const eslintRuleAgain = eslintPlugin.rules['tailwind-class-use-motion-scale'];
|
|
52
|
+
|
|
53
|
+
async function runAudit(): Promise<AuditContractReport> {
|
|
54
|
+
const report: AuditReport = await createAuditReport({ dir: './src', noConfig: true });
|
|
55
|
+
const viaPlugin: AuditReport = await audit.createAuditReport({ dir: './src' });
|
|
56
|
+
void viaPlugin;
|
|
57
|
+
return toAuditContractReport(report);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void pluginConfigs;
|
|
61
|
+
void ruleOptions;
|
|
62
|
+
void fixable;
|
|
63
|
+
void docUrl;
|
|
64
|
+
void name;
|
|
65
|
+
void presetNames;
|
|
66
|
+
void preset;
|
|
67
|
+
void presetsAgain;
|
|
68
|
+
void eslintRule;
|
|
69
|
+
void eslintRuleAgain;
|
|
70
|
+
void runAudit;
|
package/types/audit.d.ts
CHANGED
|
@@ -23,22 +23,28 @@ export interface AuditTokenSource {
|
|
|
23
23
|
export interface AuditOptions {
|
|
24
24
|
baseFontSize?: number;
|
|
25
25
|
baselinePath?: string;
|
|
26
|
-
config
|
|
26
|
+
/** Path to a `.rhythmguardrc.json`-style config. Defaults to `.rhythmguardrc.json` in `cwd`. */
|
|
27
|
+
configPath?: string;
|
|
27
28
|
dir?: string;
|
|
28
29
|
failOnNewDrift?: boolean;
|
|
29
|
-
format?: "json" | "json-v1" | "markdown" | "text" | "html";
|
|
30
|
+
format?: "json" | "json-v1" | "markdown" | "text" | "html" | "github";
|
|
30
31
|
ignorePath?: string;
|
|
31
32
|
ignorePatterns?: string[];
|
|
32
33
|
includeMotion?: boolean;
|
|
33
34
|
maxFindings?: number;
|
|
34
35
|
minCleanliness?: number;
|
|
35
|
-
|
|
36
|
+
/** Skip config discovery entirely (equivalent to `--no-config`). */
|
|
37
|
+
noConfig?: boolean;
|
|
38
|
+
/** Write rendered output to this file instead of stdout (equivalent to `--output`). */
|
|
39
|
+
outputPath?: string;
|
|
36
40
|
scale?: Array<number | string>;
|
|
37
41
|
since?: string;
|
|
38
42
|
sinceBaseline?: boolean;
|
|
39
43
|
staged?: boolean;
|
|
40
44
|
tokenCandidateMinCount?: number;
|
|
41
45
|
tokenKind?: AuditTokenKind;
|
|
46
|
+
/** Format applied to `tokenSources` entries that do not declare their own. */
|
|
47
|
+
tokenSourceFormat?: AuditTokenSourceFormat | "auto";
|
|
42
48
|
tokenSources?: AuditTokenSource[];
|
|
43
49
|
writeBaseline?: boolean;
|
|
44
50
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export interface RhythmguardPlugin extends Array<StylelintRuleModule> {
|
|
|
39
39
|
logical: RhythmguardStylelintConfig;
|
|
40
40
|
migration: RhythmguardStylelintConfig;
|
|
41
41
|
motion: RhythmguardStylelintConfig;
|
|
42
|
+
"react-tailwind": RhythmguardStylelintConfig;
|
|
42
43
|
recommended: RhythmguardStylelintConfig;
|
|
43
44
|
strict: RhythmguardStylelintConfig;
|
|
44
45
|
tailwind: RhythmguardStylelintConfig;
|