mirror of
https://github.com/antebudimir/eslint-plugin-vanilla-extract.git
synced 2026-01-02 17:43:31 +00:00
feat 🥁: initialize project with complete codebase
This commit is contained in:
commit
d569dea1fb
35 changed files with 4413 additions and 0 deletions
55
src/css-rules/custom-order/rule-definition.ts
Normal file
55
src/css-rules/custom-order/rule-definition.ts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import type { Rule } from 'eslint';
|
||||
import { availableGroups } from '../concentric-order/concentric-groups.js';
|
||||
import { createNodeVisitors } from '../shared-utils/order-strategy-visitor-creator.js';
|
||||
|
||||
interface CustomGroupRuleConfiguration {
|
||||
groupOrder?: string[];
|
||||
sortRemainingProperties: 'alphabetical' | 'concentric';
|
||||
}
|
||||
|
||||
const customGroupOrderRule: Rule.RuleModule = {
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: 'enforce custom group CSS property ordering in vanilla-extract styles',
|
||||
category: 'Stylistic Issues',
|
||||
recommended: true,
|
||||
},
|
||||
fixable: 'code',
|
||||
schema: [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
groupOrder: {
|
||||
type: 'array',
|
||||
items: {
|
||||
enum: availableGroups,
|
||||
},
|
||||
},
|
||||
sortRemainingProperties: {
|
||||
enum: ['alphabetical', 'concentric'],
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
messages: {
|
||||
incorrectOrder:
|
||||
"Property '{{nextProperty}}' should come before '{{currentProperty}}' according to custom CSS group ordering.",
|
||||
},
|
||||
},
|
||||
create(ruleContext: Rule.RuleContext) {
|
||||
const ruleConfiguration = ruleContext.options[0] as CustomGroupRuleConfiguration;
|
||||
const userDefinedGroupOrder = ruleConfiguration?.groupOrder ?? [];
|
||||
const sortRemainingPropertiesMethod = ruleConfiguration?.sortRemainingProperties ?? 'alphabetical';
|
||||
|
||||
return createNodeVisitors(
|
||||
ruleContext,
|
||||
'userDefinedGroupOrder',
|
||||
userDefinedGroupOrder,
|
||||
sortRemainingPropertiesMethod,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export default customGroupOrderRule;
|
||||
Loading…
Add table
Add a link
Reference in a new issue