Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: small changes #112

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .ecrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"exclude": [
"CHANGELOG.md",
"CONTRIBUTING.md",
"css.ts",
"pnpm-lock.yaml",
"README.md"
"README.md",
"regexps.ts"
]
}
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"check-leaks": true,
"exit": true,
"extension": ["ts"],
"extension": ["spec.ts"],
"inline-diffs": true,
"loader": "ts-node/esm",
"recursive": true,
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.czrc
.ecrc
.editorconfig
.gitattributes
.gitignore
.gitmodules
.prettierignore
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
- [CSS](#css)
- [SCSS](#scss)

- [Troubleshooting](#troubleshooting)

- [Contributing](#contributing)

- [License](#license)
Expand Down Expand Up @@ -333,6 +335,15 @@ This is a list of the lints turned on in this configuration, and what they do.
Disallow unknown properties.
Should be used instead of **Stylelint**'s `property-no-unknown`.

## Troubleshooting

If you are using **npm** you may get an error related to these plugins:

- `typescript-eslint/eslint-plugin`.
- `typescript-eslint/parser`.

To fix this you can switch to **pnpm**(recommended) or install version `6.0.0`.

## Contributing

Please read [**CONTRIBUTING**](https://github.com/archoleat/.github/blob/main/CONTRIBUTING.md)
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
"archoleat-stylelint-scss",
"archoleat-stylelint",
"archoleat",
"stylelint-config-extended-scss",
"scss",
"stylelint",
"stylelint-config-extended-scss",
"stylelint-config-standard-scss",
"stylelint-config",
"stylelint-declaration-block-no-ignored-properties",
Expand All @@ -30,12 +29,13 @@
"stylelint-order",
"stylelint-plugin-defensive-css",
"stylelint-plugin-logical-css",
"stylelint-prettier"
"stylelint-prettier",
"stylelint"
],
"homepage": "https://github.com/archoleat/stylelint-config-extended-scss#readme",
"repository": {
"type": "git",
"url": "https://github.com/archoleat/stylelint-config-extended-scss.git"
"url": "git+https://github.com/archoleat/stylelint-config-extended-scss.git"
},
"bugs": {
"url": "https://github.com/archoleat/stylelint-config-extended-scss/issues"
Expand Down
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
},
{
type: 'style',
release: 'patch',
release: false,
},
],
parserOpts: {
Expand Down
12 changes: 6 additions & 6 deletions src/properties/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ export default {
await createRule(nonStandardPseudoClassMozilla.suppressed),
await createRule(nonStandardPseudoClassMozilla.userDisabled),
await createRule(nonStandardPseudoClassMozilla.windowInactive),
await createRule(regex.NESTED.ATTRIBUTE),
await createRule(regex.NESTED.CLASS),
await createRule(regex.NESTED.MODIFIER),
await createRule(regex.NESTED.ELEMENT),
await createRule(regex.CHILD.ATTRIBUTE),
await createRule(regex.CHILD.CLASS),
await createRule(regex.NESTED.ATTRIBUTE_PATTERN),
await createRule(regex.NESTED.CLASS_PATTERN),
await createRule(regex.NESTED.MODIFIER_PATTERN),
await createRule(regex.NESTED.ELEMENT_PATTERN),
await createRule(regex.CHILD.ATTRIBUTE_PATTERN),
await createRule(regex.CHILD.CLASS_PATTERN),
'rules',
await createAtRule('include', true),
'at-rules',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
'no-descending-specificity': null,
'no-unknown-animations': true,
'selector-class-pattern': [
`^${regex.BEM.BLOCK}*${regex.BEM.ELEMENT}?${regex.BEM.MODIFIER}?$`,
`^${regex.BEM.BLOCK_PATTERN}*${regex.BEM.ELEMENT_PATTERN}?${regex.BEM.MODIFIER_PATTERN}?$`,
{
message: 'Expected lowercase class name by BEM (block__element--modifier)',
},
Expand Down
30 changes: 14 additions & 16 deletions src/utils/regexps.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
const PATTERN = '[a-z0-9]';
const SYMBOLS_PATTERN = '[a-z0-9]';
// The '?' is used to define the '&' sign at the beginning,
// which is added in createRule()
const ATTRIBUTE = '?\\[(.*)\\]';
const CLASS = '?\\.(.*)';
const MODIFIER = '--';
const ELEMENT = '__';
const ATTRIBUTE_PATTERN = '?\\[(.*)\\]';
const CLASS_PATTERN = '?\\.(.*)';
const MODIFIER_PATTERN = '--';
const ELEMENT_PATTERN = '__';

export default {
BEM: {
BLOCK: `[a-z]${PATTERN}*(-${PATTERN}+)`,
ELEMENT: `(${ELEMENT}${PATTERN}+(-${PATTERN}+)*)`,
MODIFIER: `(${MODIFIER}${PATTERN}+(-${PATTERN}+)*)`,
BLOCK_PATTERN: `[a-z]${SYMBOLS_PATTERN}*(-${SYMBOLS_PATTERN}+)`,
ELEMENT_PATTERN: `(${ELEMENT_PATTERN}${SYMBOLS_PATTERN}+(-${SYMBOLS_PATTERN}+)*)`,
MODIFIER_PATTERN: `(${MODIFIER_PATTERN}${SYMBOLS_PATTERN}+(-${SYMBOLS_PATTERN}+)*)`,
},
NESTED: {
ATTRIBUTE,
CLASS,
ELEMENT,
MODIFIER,
ATTRIBUTE_PATTERN,
CLASS_PATTERN,
ELEMENT_PATTERN,
MODIFIER_PATTERN,
},
CHILD: {
ATTRIBUTE: `${ATTRIBUTE} &`,
CLASS: `${CLASS} &`,
ATTRIBUTE_PATTERN: `${ATTRIBUTE_PATTERN} &`,
CLASS_PATTERN: `${CLASS_PATTERN} &`,
},
};

// export default REGEXP;