Merge pull request #53 from twentyhq/cbo-add-lint-in-ci

Add linter on CI
This commit is contained in:
Charles Bochet
2023-04-20 11:54:59 +02:00
committed by GitHub
21 changed files with 55 additions and 24 deletions

View File

@ -25,5 +25,7 @@ jobs:
env: env:
FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }} FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}
run: cd front && npm install run: cd front && npm install
- name: Run linter
run: cd front && npm run lint
- name: Run tests and code coverage - name: Run tests and code coverage
run: cd front && npm run coverage-ci run: cd front && npm run coverage-ci

View File

@ -3,20 +3,25 @@ module.exports = {
parserOptions: { parserOptions: {
project: 'tsconfig.json', project: 'tsconfig.json',
tsconfigRootDir: __dirname, tsconfigRootDir: __dirname,
sourceType: 'module' sourceType: 'module',
}, },
plugins: ['@typescript-eslint/eslint-plugin'], plugins: ['@typescript-eslint/eslint-plugin'],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'plugin:storybook/recommended'], extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:storybook/recommended',
'react-app',
],
root: true, root: true,
env: { env: {
node: true, node: true,
jest: true jest: true,
}, },
ignorePatterns: ['.eslintrc.js'], ignorePatterns: ['.eslintrc.js'],
rules: { rules: {
'@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off' '@typescript-eslint/no-explicit-any': 'off',
} },
}; };

View File

@ -45,6 +45,7 @@
"babel-plugin-named-exports-order": "^0.0.2", "babel-plugin-named-exports-order": "^0.0.2",
"eslint": "^8.28.0", "eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"eslint-config-standard-with-typescript": "^23.0.0", "eslint-config-standard-with-typescript": "^23.0.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.5.1", "eslint-plugin-n": "^15.5.1",

View File

@ -27,6 +27,7 @@
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject", "eject": "react-scripts eject",
"lint": "eslint src --max-warnings=0",
"storybook": "storybook dev -p 6006 -s public", "storybook": "storybook dev -p 6006 -s public",
"build-storybook": "storybook build -s public", "build-storybook": "storybook build -s public",
"coverage": "react-scripts test --coverage --watchAll", "coverage": "react-scripts test --coverage --watchAll",
@ -94,6 +95,7 @@
"babel-plugin-named-exports-order": "^0.0.2", "babel-plugin-named-exports-order": "^0.0.2",
"eslint": "^8.28.0", "eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"eslint-config-standard-with-typescript": "^23.0.0", "eslint-config-standard-with-typescript": "^23.0.0",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.5.1", "eslint-plugin-n": "^15.5.1",

View File

@ -34,7 +34,7 @@ function PersonChip({ name, picture }: OwnProps) {
<img <img
data-testid="person-chip-image" data-testid="person-chip-image"
src={picture ? picture.toString() : PersonPlaceholder.toString()} src={picture ? picture.toString() : PersonPlaceholder.toString()}
alt="person-picture" alt="person"
/> />
{name} {name}
</StyledContainer> </StyledContainer>

View File

@ -2,11 +2,13 @@ import CompanyChip from '../CompanyChip';
import { ThemeProvider } from '@emotion/react'; import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../layout/styles/themes'; import { lightTheme } from '../../../layout/styles/themes';
export default { const component = {
title: 'CompanyChip', title: 'CompanyChip',
component: CompanyChip, component: CompanyChip,
}; };
export default component;
export const RegularCompanyChip = () => { export const RegularCompanyChip = () => {
return ( return (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>

View File

@ -2,11 +2,13 @@ import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../layout/styles/themes'; import { lightTheme } from '../../../layout/styles/themes';
import PersonChip from '../PersonChip'; import PersonChip from '../PersonChip';
export default { const component = {
title: 'PersonChip', title: 'PersonChip',
component: PersonChip, component: PersonChip,
}; };
export default component;
export const RegularPersonChip = () => { export const RegularPersonChip = () => {
return ( return (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>

View File

@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
import { import {
RegularCompanyChip, RegularCompanyChip,
RegularCompanyChipWithImage, RegularCompanyChipWithImage,
} from '../__stories__/CompanyChip'; } from '../__stories__/CompanyChip.stories';
it('Checks the CompanyChip renders', () => { it('Checks the CompanyChip renders', () => {
const { getByText } = render(<RegularCompanyChip />); const { getByText } = render(<RegularCompanyChip />);

View File

@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
import { import {
RegularPersonChip, RegularPersonChip,
RegularPersonChipWithImage, RegularPersonChipWithImage,
} from '../__stories__/PersonChip'; } from '../__stories__/PersonChip.stories';
it('Checks the PersonChip renders', () => { it('Checks the PersonChip renders', () => {
const { getByText, getByTestId } = render(<RegularPersonChip />); const { getByText, getByTestId } = render(<RegularPersonChip />);

View File

@ -2,11 +2,13 @@ import Checkbox from '../Checkbox';
import { ThemeProvider } from '@emotion/react'; import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../layout/styles/themes'; import { lightTheme } from '../../../layout/styles/themes';
export default { const component = {
title: 'Checkbox', title: 'Checkbox',
component: Checkbox, component: Checkbox,
}; };
export default component;
export const RegularCheckbox = () => { export const RegularCheckbox = () => {
return ( return (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>

View File

@ -3,11 +3,13 @@ import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../../layout/styles/themes'; import { lightTheme } from '../../../../layout/styles/themes';
import { faArrowDown } from '@fortawesome/pro-regular-svg-icons'; import { faArrowDown } from '@fortawesome/pro-regular-svg-icons';
export default { const component = {
title: 'SortAndFilterBar', title: 'SortAndFilterBar',
component: SortAndFilterBar, component: SortAndFilterBar,
}; };
export default component;
type OwnProps = { type OwnProps = {
removeFunction: () => void; removeFunction: () => void;
}; };

View File

@ -3,11 +3,13 @@ import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../../layout/styles/themes'; import { lightTheme } from '../../../../layout/styles/themes';
import { faArrowDown } from '@fortawesome/pro-regular-svg-icons'; import { faArrowDown } from '@fortawesome/pro-regular-svg-icons';
export default { const component = {
title: 'SortOrFilterChip', title: 'SortOrFilterChip',
component: SortOrFilterChip, component: SortOrFilterChip,
}; };
export default component;
type OwnProps = { type OwnProps = {
removeFunction: () => void; removeFunction: () => void;
}; };

View File

@ -3,11 +3,13 @@ import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../../layout/styles/themes'; import { lightTheme } from '../../../../layout/styles/themes';
import { faBuilding } from '@fortawesome/pro-regular-svg-icons'; import { faBuilding } from '@fortawesome/pro-regular-svg-icons';
export default { const component = {
title: 'TableHeader', title: 'TableHeader',
component: TableHeader, component: TableHeader,
}; };
export default component;
export const RegularTableHeader = () => { export const RegularTableHeader = () => {
return ( return (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>

View File

@ -1,9 +1,9 @@
const onOutsideClick = jest.fn();
import { useRef } from 'react'; import { useRef } from 'react';
import TableHeader from '../../components/table/table-header/TableHeader'; import TableHeader from '../../components/table/table-header/TableHeader';
import { render, fireEvent } from '@testing-library/react'; import { render, fireEvent } from '@testing-library/react';
import { useOutsideAlerter } from '../useOutsideAlerter'; import { useOutsideAlerter } from '../useOutsideAlerter';
import { act } from 'react-dom/test-utils'; import { act } from 'react-dom/test-utils';
const onOutsideClick = jest.fn();
function TestComponent() { function TestComponent() {
const buttonRef = useRef(null); const buttonRef = useRef(null);

View File

@ -17,5 +17,5 @@ export function useOutsideAlerter(
return () => { return () => {
document.removeEventListener('mousedown', handleClickOutside); document.removeEventListener('mousedown', handleClickOutside);
}; };
}, [ref]); }, [ref, callback]);
} }

View File

@ -3,11 +3,13 @@ import AppLayout from '../AppLayout';
import { ThemeProvider } from '@emotion/react'; import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../styles/themes'; import { lightTheme } from '../styles/themes';
export default { const component = {
title: 'AppLayout', title: 'AppLayout',
component: AppLayout, component: AppLayout,
}; };
export default component;
export const AppLayoutDefault = () => ( export const AppLayoutDefault = () => (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>
<MemoryRouter> <MemoryRouter>

View File

@ -9,7 +9,7 @@ const StyledContainer = styled.div`
align-items: center; align-items: center;
`; `;
function HorizontalyAlignedContainer({ children: children }: OwnProps) { function HorizontalyAlignedContainer({ children }: OwnProps) {
return <StyledContainer>{children}</StyledContainer>; return <StyledContainer>{children}</StyledContainer>;
} }

View File

@ -5,11 +5,13 @@ import { ThemeProvider } from '@emotion/react';
import NavItem from '../../../layout/navbar/NavItem'; import NavItem from '../../../layout/navbar/NavItem';
import { lightTheme } from '../../styles/themes'; import { lightTheme } from '../../styles/themes';
export default { const component = {
title: 'NavItem', title: 'NavItem',
component: NavItem, component: NavItem,
}; };
export default component;
export const NavItemDefault = () => ( export const NavItemDefault = () => (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>
<MemoryRouter> <MemoryRouter>

View File

@ -4,11 +4,13 @@ import Navbar from '../Navbar';
import { ThemeProvider } from '@emotion/react'; import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../styles/themes'; import { lightTheme } from '../../styles/themes';
export default { const component = {
title: 'Navbar', title: 'Navbar',
component: Navbar, component: Navbar,
}; };
export default component;
export const NavbarOnCompanies = () => { export const NavbarOnCompanies = () => {
return ( return (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>

View File

@ -2,13 +2,14 @@ import { MemoryRouter } from 'react-router-dom';
import Companies from '../Companies'; import Companies from '../Companies';
import { ThemeProvider } from '@emotion/react'; import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../layout/styles/themes'; import { lightTheme } from '../../../layout/styles/themes';
import AppLayout from '../../../layout/AppLayout';
export default { const component = {
title: 'Companies', title: 'Companies',
component: Companies, component: Companies,
}; };
export default component;
export const CompaniesDefault = () => ( export const CompaniesDefault = () => (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>
<MemoryRouter> <MemoryRouter>

View File

@ -3,11 +3,13 @@ import People from '../People';
import { ThemeProvider } from '@emotion/react'; import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../layout/styles/themes'; import { lightTheme } from '../../../layout/styles/themes';
export default { const component = {
title: 'People', title: 'People',
component: People, component: People,
}; };
export default component;
export const PeopleDefault = () => ( export const PeopleDefault = () => (
<ThemeProvider theme={lightTheme}> <ThemeProvider theme={lightTheme}>
<MemoryRouter> <MemoryRouter>