Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjwest committed Feb 22, 2023
1 parent 7980b55 commit c287f99
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const DEFAULT_OPTIONS = {
selector: '&',
element: '_',
modifier: '-',
}
};

function escapeRegex(string: string) {
return string
Expand All @@ -35,7 +35,7 @@ export function createMatchers(options: Options): Matchers {
selectorRegex: new RegExp(`^(${selector})+`),
elementSelectorRegex: new RegExp(`^((${selector})+)${escapeRegex(options.element)}`),
modifierSelectorRegex: new RegExp(`^((${selector})+)${escapeRegex(options.modifier)}`),
}
};
}

export function replaceClass(classAttr: string, matchers: Matchers, baseClass?: string) {
Expand Down Expand Up @@ -128,5 +128,5 @@ export default function expandClassesDecorator(options?: Partial<Options>) {
return expandClasses(original.apply(this, args), options);
};
return descriptor;
}
};
}
4 changes: 2 additions & 2 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('expandClasses', () => {
}
}

const element = React.createElement(TestFunctionComponent, {name: 'Anna', age: 72}, null);
const element = React.createElement(TestFunctionComponent, { name: 'Anna', age: 72 }, null);
const root = parser.parse(ReactDom.renderToString(element));

assert.strictEqual(root.querySelector('section').attrs.class, 'User User-active');
Expand All @@ -33,4 +33,4 @@ describe('expandClasses', () => {
assert.strictEqual(root.querySelector('li:nth-child(2)').attrs.class, 'User_age');
assert.strictEqual(root.querySelector('span').attrs.class, 'User_name_text User_name_text-highlight');
});
})
});
12 changes: 6 additions & 6 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { TestFunctionComponent, TestDecoratorComponent } from './components';
const DEFAULT_MATCHERS = createMatchers(DEFAULT_OPTIONS);

function getElement(root: HTMLElement, selector: string): HTMLElement {
const element = root.querySelector(selector)
if (!element) throw Error(`Element "${selector}" not found`)
return element
const element = root.querySelector(selector);
if (!element) throw Error(`Element "${selector}" not found`);
return element;
}

describe('replaceClass', () => {
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('replaceClass', () => {

describe('expandClasses', () => {
it('Maps classes in a component', () => {
const element = createElement(TestFunctionComponent, {name: 'Anna', age: 72}, null);
const element = createElement(TestFunctionComponent, { name: 'Anna', age: 72 }, null);
const root = parse(renderToString(element));

assert.strictEqual(getElement(root, 'section').attrs.class, 'User User-active');
Expand All @@ -106,11 +106,11 @@ describe('expandClasses', () => {
assert.strictEqual(getElement(root, 'form').attrs.class, 'User_actions');
assert.strictEqual(getElement(root, 'button').attrs.class, 'User_actions_action');
});
})
});

describe('expandClassesDecorator', () => {
it('Maps classes in a component', () => {
const element = createElement(TestDecoratorComponent, {name: 'Anna', age: 72}, null);
const element = createElement(TestDecoratorComponent, { name: 'Anna', age: 72 }, null);
const root = parse(renderToString(element));

assert.strictEqual(getElement(root, 'section').attrs.class, 'User User-active');
Expand Down

0 comments on commit c287f99

Please sign in to comment.