Skip to content

Commit

Permalink
refactor: order
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkeyl committed Jan 14, 2025
1 parent ff9dab6 commit feaf39b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"stylelint": "^15.0.0 || ^16.0.0"
},
"dependencies": {
"@archoleat/reglib": "^1.5.3",
"@archoleat/reglib": "^1.6.0",
"prettier": "^3.4.2",
"stylelint": "^16.13.2",
"stylelint-config-standard-scss": "^14.0.0",
Expand Down
51 changes: 34 additions & 17 deletions src/config/properties/order.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import { selectors } from '@archoleat/reglib';
import {
ATTRIBUTE_CHILD_REGEX,
ATTRIBUTE_REGEX,
ATTRIBUTE_SIBLING_REGEX,
CHILD_REGEX,
CLASS_CHILD_REGEX,
CLASS_REGEX,
CLASS_SIBLING_REGEX,
ELEMENT_REGEX,
MODIFIER_REGEX,
NESTED_ATTRIBUTE_CHILD_REGEX,
NESTED_ATTRIBUTE_REGEX,
NESTED_ATTRIBUTE_SIBLING_REGEX,
NESTED_CLASS_CHILD_REGEX,
NESTED_CLASS_REGEX,
NESTED_CLASS_SIBLING_REGEX,
SIBLING_REGEX,
} from '@archoleat/reglib';

import { createAtRule } from '#utils/create-at-rule/create-at-rule.ts';
import { createRule } from '#utils/create-rule/create-rule.ts';
Expand Down Expand Up @@ -185,52 +202,52 @@ const propertiesOrder = {
await createRule({ selector: nonStandardPseudoClassMozilla.userDisabled }),
await createRule({ selector: nonStandardPseudoClassMozilla.windowInactive }),
await createRule({
selector: new RegExp(`^${selectors.NESTED_ATTRIBUTE_REGEX}$`),
selector: new RegExp(`^${NESTED_ATTRIBUTE_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.NESTED_ATTRIBUTE_SIBLING_REGEX}$`),
selector: new RegExp(`^${NESTED_ATTRIBUTE_SIBLING_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.NESTED_ATTRIBUTE_CHILD_REGEX}$`),
selector: new RegExp(`^${NESTED_ATTRIBUTE_CHILD_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.NESTED_CLASS_REGEX}$`),
selector: new RegExp(`^${NESTED_CLASS_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.NESTED_CLASS_SIBLING_REGEX}$`),
selector: new RegExp(`^${NESTED_CLASS_SIBLING_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.NESTED_CLASS_CHILD_REGEX}$`),
selector: new RegExp(`^${NESTED_CLASS_CHILD_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.MODIFIER_REGEX}$`),
selector: new RegExp(`^${MODIFIER_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.ELEMENT_REGEX}$`),
selector: new RegExp(`^${ELEMENT_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.ATTRIBUTE_REGEX}$`),
selector: new RegExp(`^${ATTRIBUTE_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.ATTRIBUTE_SIBLING_REGEX}$`),
selector: new RegExp(`^${ATTRIBUTE_SIBLING_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.ATTRIBUTE_CHILD_REGEX}$`),
selector: new RegExp(`^${ATTRIBUTE_CHILD_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.CLASS_REGEX}$`),
selector: new RegExp(`^${CLASS_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.CLASS_SIBLING_REGEX}$`),
selector: new RegExp(`^${CLASS_SIBLING_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.CLASS_CHILD_REGEX}$`),
selector: new RegExp(`^${CLASS_CHILD_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.SIBLING_REGEX}$`),
selector: new RegExp(`^${SIBLING_REGEX}$`),
}),
await createRule({
selector: new RegExp(`^${selectors.CHILD_REGEX}$`),
selector: new RegExp(`^${CHILD_REGEX}$`),
}),
'rules',
await createAtRule({ name: 'include', hasBlock: true }),
Expand Down
8 changes: 2 additions & 6 deletions src/config/rules/css.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { selectors } from '@archoleat/reglib';
import { BLOCK_REGEX, ELEMENT_REGEX, MODIFIER_REGEX } from '@archoleat/reglib';

import { messages } from '#data/messages.ts';

const BLOCK = selectors.bem.BLOCK_REGEX;
const ELEMENT = selectors.bem.ELEMENT_REGEX;
const MODIFIER = selectors.bem.MODIFIER_REGEX;

const CSSRules = {
'at-rule-disallowed-list': ['debug'],
'at-rule-empty-line-before': [
Expand Down Expand Up @@ -42,7 +38,7 @@ const CSSRules = {
'no-descending-specificity': null,
'no-unknown-animations': true,
'selector-class-pattern': [
`^(?:${BLOCK})(?:${ELEMENT})?(?:${MODIFIER})?$`,
`^(?:${BLOCK_REGEX})(?:${ELEMENT_REGEX})?(?:${MODIFIER_REGEX})?$`,
{
message: messages.bem,
},
Expand Down

0 comments on commit feaf39b

Please sign in to comment.