Skip to content

Commit

Permalink
fix(regex): change name (#113)
Browse files Browse the repository at this point in the history
Co-authored-by: Almanov Nikita <131481562+nikkeyl@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and nikkeyl authored Mar 14, 2024
1 parent d45fece commit f8e04c9
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
12 changes: 6 additions & 6 deletions specs/regex/regex.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';

import REGEXP from '../../src/utils/regexps.ts';
import regex from '../../src/utils/regexps.ts';

describe('Nested Selectors Pattern', () => {
const NESTED_ATTRIBUTE = REGEXP.NESTED.ATTRIBUTE;
const NESTED_CLASS = REGEXP.NESTED.CLASS;
const NESTED_MODIFIER = REGEXP.NESTED.MODIFIER;
const CHILD_ATTRIBUTE = REGEXP.CHILD.ATTRIBUTE;
const CHILD_CLASS = REGEXP.CHILD.CLASS;
const NESTED_ATTRIBUTE = regex.nested.ATTRIBUTE_PATTERN;
const NESTED_CLASS = regex.nested.CLASS_PATTERN;
const NESTED_MODIFIER = regex.nested.MODIFIER_PATTERN;
const CHILD_ATTRIBUTE = regex.child.ATTRIBUTE_PATTERN;
const CHILD_CLASS = regex.child.CLASS_PATTERN;

it('nested (&[attribute)', () => {
expect('&[attribute]').to.match(new RegExp(`&${NESTED_ATTRIBUTE}`));
Expand Down
2 changes: 2 additions & 0 deletions src/creators/at-rule.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
* The asynchronous `createAtRule` function in TypeScript creates an object
* representing an at-rule with a specified name and block presence.
*
* @param {string} name - The `name` parameter is a string that represents
* the name of the at-rule being created.
*
* @param {boolean} hasBlock - The `hasBlock` parameter in the `createAtRule`
* function is a boolean value that indicates whether the at-rule being created
* will have a block of nested rules or declarations inside it. If `hasBlock`
Expand Down
2 changes: 2 additions & 0 deletions src/creators/logical-group.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
* The asynchronous function `createLogicalGroup` creates a logical group
* with specified properties and formatting rules.
*
* @param {string} groupName - The `groupName` parameter is a string that
* represents the name of the logical group being created.
*
* @param {string[]} properties - The `properties` parameter in the
* `createLogicalGroup` function is an array that contains the properties
* or items that you want to group together under a logical group
Expand Down
1 change: 1 addition & 0 deletions src/creators/rule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* The asynchronous function `createRule` in TypeScript creates
* a CSS rule with a specified selector.
*
* @param {string} selector - The `selector` parameter in the `createRule`
* function is a string that
* represents the CSS selector for which a rule is being created.
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_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),
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,

Check warning on line 17 in src/rules/css.ts

View workflow job for this annotation

GitHub Actions / Lint

Use `undefined` instead of `null`
'no-unknown-animations': true,
'selector-class-pattern': [
`^${regex.BEM.BLOCK_PATTERN}*${regex.BEM.ELEMENT_PATTERN}?${regex.BEM.MODIFIER_PATTERN}?$`,
`^${regex.bem.BLOCK_PATTERN}*${regex.bem.ELEMENT_PATTERN}?${regex.bem.MODIFIER_PATTERN}?$`,
{
message: 'Expected lowercase class name by BEM (block__element--modifier)',
},
Expand Down
6 changes: 3 additions & 3 deletions src/utils/regexps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ const MODIFIER_PATTERN = '--';
const ELEMENT_PATTERN = '__';

export default {
BEM: {
bem: {
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: {
nested: {
ATTRIBUTE_PATTERN,
CLASS_PATTERN,
ELEMENT_PATTERN,
MODIFIER_PATTERN,
},
CHILD: {
child: {
ATTRIBUTE_PATTERN: `${ATTRIBUTE_PATTERN} &`,
CLASS_PATTERN: `${CLASS_PATTERN} &`,
},
Expand Down

0 comments on commit f8e04c9

Please sign in to comment.