Skip to content

Commit

Permalink
refactor: add comments (#268)
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 Sep 1, 2024
1 parent f83697f commit 4300c69
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 38 deletions.
10 changes: 5 additions & 5 deletions specs/features/at-rule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ describe('Create At Rule', () => {

beforeEach(() => {
const addAtRule = async (parameters: Parameters) => {
const { name, hasBlock, type } = parameters;
const { name, hasBlock } = parameters;

return await createAtRule({ name, hasBlock, type }).then((parameters) => {
return await createAtRule({ name, hasBlock }).then((parameters) => {
expect(parameters.name).equal(name);
expect(parameters.hasBlock).equal(hasBlock);
expect(parameters.type).equal(type);
expect(parameters.type).equal('at-rule');
});
};

atRule = addAtRule;
});

spec('create an object with (name: String, hasBlock: true)', async () => {
return await atRule({ name: 'test-rule', hasBlock: true, type: 'at-rule' });
return await atRule({ name: 'test-rule', hasBlock: true });
});

spec('create an object with (name: String, hasBlock: false)', async () => {
return await atRule({ name: 'test-rule', hasBlock: false, type: 'at-rule' });
return await atRule({ name: 'test-rule', hasBlock: false });
});
});
4 changes: 2 additions & 2 deletions specs/features/rule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('Create Rule', () => {

beforeEach(() => {
const addRule = async (parameters: Parameters) => {
const { selector, type } = parameters;
const { selector } = parameters;

return await createRule({ selector, type }).then((parameters) => {
return await createRule({ selector }).then((parameters) => {
expect(parameters.selector).equal(`&${selector}`);
expect(parameters.type).equal('rule');
});
Expand Down
19 changes: 8 additions & 11 deletions src/features/at-rule/at-rule.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import type { Parameters } from './parameters.ts';

/**
* The asynchronous `createAtRule` function in TypeScript creates an object
* representing an at-rule with a specified name and block presence.
* Creates an at-rule.
*
* @param {string} name - The `name` parameter is a string that represents
* the name of the at-rule being created.
* @param {string} name - The name of the at-rule.
*
* @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`
* is `true`, it means that the at-rule will have a block.
* @param {boolean} [hasBlock=false] - Indicates if the at-rule has a nested block.
*
* @return {Object} - The created at-rule object with the specified name,
* hasBlock flag, and type 'at-rule'.
*/

const createAtRule = async (parameters: Parameters) => {
const { name, hasBlock = false, type = 'at-rule' } = parameters;
const { name, hasBlock = false } = parameters;

return {
name,
hasBlock,
type,
type: 'at-rule',
};
};

Expand Down
1 change: 0 additions & 1 deletion src/features/at-rule/parameters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
type Parameters = {
name: string;
hasBlock?: boolean;
type?: 'at-rule';
};

export type { Parameters };
16 changes: 6 additions & 10 deletions src/features/logical-group/logical-group.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import type { Parameters } from './parameters.ts';

/**
* The asynchronous function `createLogicalGroup` creates a logical group
* with specified properties and formatting rules.
* Creates a logical group.
*
* @param {string} groupName - The `groupName` parameter is a string that
* represents the name of the logical group being created.
* @param {string} groupName - The name of the logical group.
*
* @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
* with the specified `groupName`. These properties can be of any type or
* structure, depending on your specific use case.
* @param {Array} properties - The properties within the logical group.
*
* @return {Object} - The created logical group object with
* groupName, properties, emptyLineBefore, noEmptyLineBetween, and order.
*/

const createLogicalGroup = async (parameters: Parameters) => {
const { groupName, properties } = parameters;

Expand Down
1 change: 0 additions & 1 deletion src/features/rule/parameters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
type Parameters = {
selector: string;
type?: 'rule';
};

export type { Parameters };
15 changes: 7 additions & 8 deletions src/features/rule/rule.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import type { Parameters } from './parameters.ts';

/**
* The asynchronous function `createRule` in TypeScript creates
* a CSS rule with a specified selector.
* Creates a rule.
*
* @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.
* @param {string} selector - The css selector for the rule.
*
* @return {Object} - The created rule object with type 'rule'
* and modified selector.
*/

const createRule = async (parameters: Parameters) => {
const { selector, type = 'rule' } = parameters;
const { selector } = parameters;

return {
type,
type: 'rule',
selector: `&${selector}`,
};
};
Expand Down

0 comments on commit 4300c69

Please sign in to comment.