Skip to content

Commit

Permalink
chore: update lint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS committed Nov 28, 2023
1 parent bc3514b commit 188622d
Show file tree
Hide file tree
Showing 42 changed files with 1,914 additions and 691 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
storybook-static
build
!/.storybook
48 changes: 43 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,50 @@
{
"extends": [
"@gravity-ui/eslint-config",
"@gravity-ui/eslint-config/client",
"@gravity-ui/eslint-config/import-order",
"@gravity-ui/eslint-config/prettier",
"@gravity-ui/eslint-config/client"
"@gravity-ui/eslint-config/a11y"
],
"root": true,
"env": {
"node": true,
"jest": true
}
"rules": {
"react/jsx-fragments": ["error", "element"],
"no-restricted-syntax": [
"error",
{
"selector": "ImportDeclaration[source.value='react'] :matches(ImportNamespaceSpecifier, ImportSpecifier)",
"message": "Please use import React from 'react' instead."
},
{
"selector": "TSTypeReference>TSQualifiedName[left.name='React'][right.name='FC']",
"message": "Don't use React.FC"
}
],
"jsx-a11y/no-autofocus": 0
},
"overrides": [
{
"files": ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
"env": {
"node": true,
"jest": true
},
"extends": ["plugin:testing-library/react"],
"rules": {
"jsx-a11y/no-static-element-interactions": 0
}
},
{
"files": ["**/__stories__/**/*.[jt]s?(x)"],
"rules": {
"no-console": "off"
}
},
{
"files": ["**/*.js", "!src/**/*"],
"env": {
"node": true
}
}
]
}
2 changes: 2 additions & 0 deletions .storybook/decorators/withLang.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';

import type {DecoratorFn} from '@storybook/react';

import {Lang, configure} from '../../src';

export const withLang: DecoratorFn = (Story, context) => {
Expand Down
4 changes: 3 additions & 1 deletion .storybook/decorators/withMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import type {DecoratorFn} from '@storybook/react';

import {useMobile} from '@gravity-ui/uikit';
import type {DecoratorFn} from '@storybook/react';

export const withMobile: DecoratorFn = (Story, context) => {
const mobileValue = context.globals.platform === 'mobile';

const [, setMobile] = useMobile(); // eslint-disable-line react-hooks/rules-of-hooks

// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
setMobile(mobileValue);
}, [mobileValue]);

Check warning on line 14 in .storybook/decorators/withMobile.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

React Hook React.useEffect has a missing dependency: 'setMobile'. Either include it or remove the dependency array
Expand Down
9 changes: 6 additions & 3 deletions .storybook/docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export const Docs = () => {
target="_blank"
rel="noopener noreferrer"
>
<img src="https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/icons/github-badge.svg" />
<img
alt=""
src="https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/icons/github-badge.svg"
/>
</a>
);
}
Expand All @@ -53,9 +56,9 @@ export const Docs = () => {
}

return (
<>
<React.Fragment>
{sourceBadgeContent}
{readmeContent}
</>
</React.Fragment>
);
};
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {StorybookConfig} from '@storybook/core-common';
import type {StorybookConfig} from '@storybook/react-webpack5';

const {join} = require('path');

Expand Down
1 change: 1 addition & 0 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {addons} from '@storybook/addons';

import {themes} from './theme';

addons.setConfig({
Expand Down
9 changes: 7 additions & 2 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// eslint-disable-next-line import/order
import './styles.scss';
// eslint-disable-next-line import/order
import '@gravity-ui/uikit/styles/styles.css';

import React from 'react';

import {Lang, MobileProvider, ThemeProvider, configure as uiKitConfigure} from '@gravity-ui/uikit';
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';
import type {Decorator, Preview} from '@storybook/react';
import {ThemeProvider, MobileProvider, Lang, configure as uiKitConfigure} from '@gravity-ui/uikit';

import {configure} from '../src';
import {withMobile} from './decorators/withMobile';

import {withLang} from './decorators/withLang';
import {withMobile} from './decorators/withMobile';
import {Docs} from './docs';

configure({
Expand Down
8 changes: 5 additions & 3 deletions .storybook/theme-addon/register.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as React from 'react';
import {addons, types} from '@storybook/addons';
import {useGlobals, type API} from '@storybook/api';
import React from 'react';

import {getThemeType} from '@gravity-ui/uikit';
import {addons, types} from '@storybook/addons';
import {type API, useGlobals} from '@storybook/api';

import {themes} from '../theme';

const ADDON_ID = 'yc-theme-addon';
Expand Down
Loading

0 comments on commit 188622d

Please sign in to comment.