Skip to content

Commit

Permalink
chore: eslint nx version up (#943)
Browse files Browse the repository at this point in the history
* chore: eslint nx version up

* fix: separate nx eslint

* fix: eslint
  • Loading branch information
ssong10 authored Mar 12, 2024
1 parent 79d8185 commit eecb7fc
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"root": true,
"extends": [
"plugin:@nx/typescript",
"plugin:@nx/javascript",
"@class101/eslint-config",
"plugin:storybook/recommended"
],
"plugins" :["@nx"],
"overrides": [
{
"files": [
Expand Down
6 changes: 3 additions & 3 deletions packages/utils-eslint-config/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const unusedImportsRules = require('./rules/unused-imports');

/** @type {import('eslint').ESLint.ConfigData} */
const eslintConfig = {
extends: ['plugin:@nx/javascript', 'prettier'],
plugins: ['@nx', 'prettier', 'react', 'react-hooks', 'import', 'unused-imports'],
extends: ['prettier'],
plugins: ['prettier', 'react', 'react-hooks', 'import', 'unused-imports'],
parserOptions: {
ecmaFeatures: {
jsx: true,
Expand All @@ -30,7 +30,7 @@ const eslintConfig = {
overrides: [
{
files: ['*.ts', '*.tsx'],
extends: ['plugin:@nx/typescript'],
extends: [],
rules: {
...typescriptRules,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ export const VirtualizedTable = <Data extends Record<string, any>, RowKey extend
const getColumnsCount = () => {
let columnsNum = columns.length;

if (selectable) columnsNum += 1;
if (selectable) {
columnsNum += 1;
}

if (renderExpanded) columnsNum += 1;
if (renderExpanded) {
columnsNum += 1;
}

return columnsNum;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ describe('<BreadCrumbs />', () => {

it('non last BreadCrumb should have onView2 color', () => {
breadcrumbTexts.forEach((text, idx, arr) => {
if (idx === arr.length - 1) return;
if (idx === arr.length - 1) {
return;
}

expect(text).toHaveStyleRule('color', lightModeColors.onView2);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('<ContainedButton />', () => {
expect(renderer.queryByTestId('button-text')).toHaveStyleRule('color', contentColor);
});

describe(`and button clicked`, () => {
describe('and button clicked', () => {
beforeEach(() => {
fireEvent.click(element);
});
Expand All @@ -58,7 +58,7 @@ describe('<ContainedButton />', () => {
});
});

describe(`and mouse hovered`, () => {
describe('and mouse hovered', () => {
beforeEach(() => {
fireEvent.mouseOver(element);
});
Expand All @@ -72,7 +72,7 @@ describe('<ContainedButton />', () => {
});
});

describe(`and focused`, () => {
describe('and focused', () => {
beforeEach(() => {
fireEvent.focusIn(element);
});
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('<ContainedButton />', () => {
expect(renderer.queryByTestId('button-text')).toHaveStyleRule('color', contentColor);
});

describe(`and button clicked`, () => {
describe('and button clicked', () => {
beforeEach(() => {
fireEvent.click(element);
});
Expand All @@ -123,7 +123,7 @@ describe('<ContainedButton />', () => {
});
});

describe(`and mouse hovered`, () => {
describe('and mouse hovered', () => {
beforeEach(() => {
fireEvent.mouseOver(element);
});
Expand All @@ -137,7 +137,7 @@ describe('<ContainedButton />', () => {
});
});

describe(`and focused`, () => {
describe('and focused', () => {
beforeEach(() => {
fireEvent.focusIn(element);
});
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('<ContainedButton />', () => {
});
});

describe(`and button clicked`, () => {
describe('and button clicked', () => {
beforeEach(() => {
fireEvent.click(element);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ export const PopoverOpener = withPopoverOpenerVariation(
({ popoverId = '', openInteraction, isOpen, open, close, children }) => {
const { isOpen: registeredIsOpen, open: registeredOpen, close: registeredClose } = usePopover({ id: popoverId });
const toggleOpener = () => {
if (popoverId) return registeredIsOpen ? registeredClose?.() : registeredOpen?.();
if (popoverId) {
return registeredIsOpen ? registeredClose?.() : registeredOpen?.();
}

return isOpen ? close?.() : open?.();
};
const openOpener = () => {
if (popoverId) return registeredOpen?.();
if (popoverId) {
return registeredOpen?.();
}

return open?.();
};
const closeOpener = () => {
if (popoverId) return registeredClose?.();
if (popoverId) {
return registeredClose?.();
}

return close?.();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ export const TableRow = withTableRowVariation(
const getColumnsCount = () => {
let columnsNum = Children.count(children);

if (selectable) columnsNum += 1;
if (selectable) {
columnsNum += 1;
}

if (expandable) columnsNum += 1;
if (expandable) {
columnsNum += 1;
}

return columnsNum;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ export const isStringFilterValid = (filter: { value: string; operator: StringFil
Boolean(filter.value) || isValueRequiredOperator(filter.operator);

export const isDateFilterValid = (filter: { value: Date[]; operator: DateFilterOperator }) => {
if (isValueRequiredOperator(filter.operator)) return true;
if (isValueRequiredOperator(filter.operator)) {
return true;
}

if (filter.operator === 'between') return filter.value.length >= 2;
if (filter.operator === 'between') {
return filter.value.length >= 2;
}

return filter.value.length >= 1;
};
Expand Down
20 changes: 15 additions & 5 deletions packages/vibrant-core/src/lib/PopoverProvider/PopoverProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export const PopoverProvider: FC<PopoverProviderProps> = ({ children }) => {

const open = useCallback(
(id: string) => {
if (!checkIsRegistered(id)) return;
if (!checkIsRegistered(id)) {
return;
}

popovers.current.set(id, true);

Expand All @@ -44,7 +46,9 @@ export const PopoverProvider: FC<PopoverProviderProps> = ({ children }) => {
);
const close = useCallback(
(id: string) => {
if (!checkIsRegistered(id)) return;
if (!checkIsRegistered(id)) {
return;
}

setCount(count => count + 1);

Expand Down Expand Up @@ -91,7 +95,9 @@ export const usePopover = ({ id = '', value }: { id?: string; value?: boolean |
const { getIsOpen, open, close, registerPopover, unregisterPopover, checkIsRegistered } = useContext(PopoverContext);
const [nonRegisteredIsOpen, setNonRegisteredIsOpen] = useState(value);

if (checkIsRegistered(id) === undefined) throw Error('Provider cannot be found');
if (checkIsRegistered(id) === undefined) {
throw Error('Provider cannot be found');
}

const isOpen = checkIsRegistered(id) ? getIsOpen(id) : nonRegisteredIsOpen;

Expand All @@ -112,10 +118,14 @@ export const usePopover = ({ id = '', value }: { id?: string; value?: boolean |
}, [checkIsRegistered, close, id]);

useEffect(() => {
if (id) registerPopover(id);
if (id) {
registerPopover(id);
}

return () => {
if (id) unregisterPopover(id);
if (id) {
unregisterPopover(id);
}
};
}, [id, registerPopover, unregisterPopover]);

Expand Down

0 comments on commit eecb7fc

Please sign in to comment.