Skip to content

Commit

Permalink
refactor: change export type (#146)
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 28, 2024
1 parent 5f2f1a0 commit d9cf847
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 30 deletions.
2 changes: 1 addition & 1 deletion specs/creators/at-rule.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, test } from 'vitest';

import createAtRule from '../../src/creators/at-rule.ts';
import { createAtRule } from '../../src/creators/at-rule.ts';

describe('Create At Rule', () => {
let atRule: Function;
Expand Down
2 changes: 1 addition & 1 deletion specs/creators/logical-group.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from 'vitest';

import createLogicalGroup from '../../src/creators/logical-group.ts';
import { createLogicalGroup } from '../../src/creators/logical-group.ts';

describe('Create Logical Group', () => {
test('create an object with (groupName: String, properties: [])', async () => {
Expand Down
2 changes: 1 addition & 1 deletion specs/creators/rule.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, test } from 'vitest';

import createRule from '../../src/creators/rule.ts';
import { createRule } from '../../src/creators/rule.ts';

describe('Create Rule', () => {
let rule: Function;
Expand Down
2 changes: 1 addition & 1 deletion specs/regex/bem-pattern.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from 'vitest';

import CSSRules from '../../src/rules/css.ts';
import { CSSRules } from '../../src/rules/css.ts';

describe('BEM Class Pattern', () => {
const BEMClassPattern = new RegExp(
Expand Down
2 changes: 1 addition & 1 deletion specs/regex/regex.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from 'vitest';

import regex from '../../src/utils/regexps.ts';
import { regex } from '../../src/utils/regexps.ts';

describe('Nested Selectors Pattern', () => {
const NESTED_ATTRIBUTE = regex.nested.ATTRIBUTE_PATTERN;
Expand Down
4 changes: 3 additions & 1 deletion src/creators/at-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
* will have a block of nested rules or declarations inside it. If `hasBlock`
* is `true`, it means that the at-rule will have a block.
*/
export default async (name: string, hasBlock: boolean) => ({
const createAtRule = async (name: string, hasBlock: boolean) => ({
name,
hasBlock,
type: 'at-rule',
});

export { createAtRule };
4 changes: 3 additions & 1 deletion src/creators/logical-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
* with the specified `groupName`. These properties can be of any type or
* structure, depending on your specific use case.
*/
export default async (groupName: string, properties: string[]) => ({
const createLogicalGroup = async (groupName: string, properties: string[]) => ({
groupName,
properties,
emptyLineBefore: 'always',
noEmptyLineBetween: true,
order: 'flexible',
});

export { createLogicalGroup };
4 changes: 3 additions & 1 deletion src/creators/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* function is a string that
* represents the CSS selector for which a rule is being created.
*/
export default async (selector: string) => ({
const createRule = async (selector: string) => ({
selector: `&${selector}`,
type: 'rule',
});

export { createRule };
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CSSRules from './rules/css.ts';
import SCSSRules from './rules/scss.ts';
import { CSSRules } from './rules/css.ts';
import { SCSSRules } from './rules/scss.ts';

import plugins from './utils/plugins.ts';
import { plugins } from './utils/plugins.ts';

export default {
extends: ['stylelint-config-standard-scss', 'stylelint-prettier/recommended'],
Expand Down
4 changes: 3 additions & 1 deletion src/properties/deprecated.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
const deprecated = {
property: {
float: 'float',
clear: 'clear',
Expand Down Expand Up @@ -84,3 +84,5 @@ export default {
},
},
};

export { deprecated };
4 changes: 3 additions & 1 deletion src/properties/experimental.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
const experimental = {
pseudo: {
element: {
targetText: '::target-text',
Expand Down Expand Up @@ -74,3 +74,5 @@ export default {
},
},
};

export { experimental };
4 changes: 3 additions & 1 deletion src/properties/non-standard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
const nonStandard = {
pseudo: {
element: {
webkit: {
Expand Down Expand Up @@ -70,3 +70,5 @@ export default {
zoom: 'zoom',
},
};

export { nonStandard };
18 changes: 10 additions & 8 deletions src/properties/order.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import regex from '../utils/regexps.ts';
import { regex } from '../utils/regexps.ts';

import deprecated from './deprecated.ts';
import experimental from './experimental.ts';
import nonStandard from './non-standard.ts';
import { deprecated } from './deprecated.ts';
import { experimental } from './experimental.ts';
import { nonStandard } from './non-standard.ts';

import createAtRule from '../creators/at-rule.ts';
import createLogicalGroup from '../creators/logical-group.ts';
import createRule from '../creators/rule.ts';
import { createAtRule } from '../creators/at-rule.ts';
import { createLogicalGroup } from '../creators/logical-group.ts';
import { createRule } from '../creators/rule.ts';

const experimentPseudoElement = experimental.pseudo.element;
const experimentPseudoElementMozilla = experimental.pseudo.element.moz;
Expand All @@ -21,7 +21,7 @@ const deprecatedProperty = deprecated.property;
const experimentalProperty = experimental.property;
const nonStandardProperty = nonStandard.property;

export default {
const propertiesOrder = {
'order/order': [
'custom-properties',
'dollar-variables',
Expand Down Expand Up @@ -675,3 +675,5 @@ export default {
},
],
};

export { propertiesOrder };
6 changes: 4 additions & 2 deletions src/rules/css.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import regex from '../utils/regexps.ts';
import { regex } from '../utils/regexps.ts';

export default {
const CSSRules = {
'at-rule-disallowed-list': ['debug'],
'color-named': 'never',
'declaration-no-important': true,
Expand Down Expand Up @@ -34,3 +34,5 @@ export default {
},
],
};

export { CSSRules };
4 changes: 3 additions & 1 deletion src/rules/scss.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const namedArguments = ['always', { ignore: ['single-argument'] }];

export default {
const SCSSRules = {
'scss/at-each-key-value-single-line': true,
'scss/at-function-named-arguments': namedArguments,
'scss/at-mixin-named-arguments': namedArguments,
Expand All @@ -27,3 +27,5 @@ export default {
'scss/property-no-unknown': true,
'scss/selector-no-redundant-nesting-selector': true,
};

export { SCSSRules };
6 changes: 4 additions & 2 deletions src/utils/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import propertiesOrder from '../properties/order.ts';
import { propertiesOrder } from '../properties/order.ts';

export default {
const plugins = {
'gamut/color-no-out-gamut-range': true,
'plugin/stylelint-group-selectors': true,
'plugin/declaration-block-no-ignored-properties': true,
Expand All @@ -21,3 +21,5 @@ export default {
'plugin/use-logical-units': true,
...propertiesOrder,
};

export { plugins };
6 changes: 3 additions & 3 deletions src/utils/regexps.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
const SYMBOLS_PATTERN = '[a-z0-9]';
// The '?' is used to define the '&' sign at the beginning,
// which is added in createRule()
const ATTRIBUTE_PATTERN = '?\\[(.*)\\]';
const CLASS_PATTERN = '?\\.(.*)';
const MODIFIER_PATTERN = '--';
const ELEMENT_PATTERN = '__';

export default {
const regex = {
bem: {
BLOCK_PATTERN: `[a-z]${SYMBOLS_PATTERN}*(-${SYMBOLS_PATTERN}+)`,
ELEMENT_PATTERN: `(${ELEMENT_PATTERN}${SYMBOLS_PATTERN}+(-${SYMBOLS_PATTERN}+)*)`,
Expand All @@ -23,3 +21,5 @@ export default {
CLASS_PATTERN: `${CLASS_PATTERN} &`,
},
};

export { regex };

0 comments on commit d9cf847

Please sign in to comment.