Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update lint rules #124

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
]
}
57 changes: 28 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,36 @@ jobs:
name: Verify Files
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
cache: npm
- name: Install Packages
run: npm ci
- name: Lint Files
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
cache: npm
- name: Install Packages
run: npm ci
- name: Lint Files
run: npm run lint
- name: Typecheck
run: npm run typecheck

tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
cache: npm
- name: Install Packages
run: npm ci
- name: Unit Tests
run: npm run test

- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 18
cache: npm
- name: Install Packages
run: npm ci
- name: Unit Tests
run: npm run test
6 changes: 3 additions & 3 deletions .github/workflows/pr-preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: gravity-ui/preview-build-action@v1
with:
node-version: 18
- uses: gravity-ui/preview-build-action@v1
with:
node-version: 18
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: gravity-ui/release-action@v1
with:
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }}
node-version: 18
- uses: gravity-ui/release-action@v1
with:
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }}
node-version: 18
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ storybook-static
dist
CHANGELOG.md
CONTRIBUTING.md
package-lock.json
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,15 +1,17 @@
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

return <Story {...context} />;
};
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 All @@ -23,7 +23,7 @@

// to turn fileName in context.parameters into path form number in production bundle
if (storybookBaseConfig?.optimization) {
storybookBaseConfig.optimization.moduleIds = 'named';

Check warning on line 26 in .storybook/main.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Assignment to property of function parameter 'storybookBaseConfig'
}

return storybookBaseConfig;
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 All @@ -21,6 +23,6 @@
const [{theme}] = useGlobals();
React.useEffect(() => {
api.setOptions({theme: themes[getThemeType(theme)]});
}, [theme]);

Check warning on line 26 in .storybook/theme-addon/register.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

React Hook React.useEffect has a missing dependency: 'api'. Either include it or remove the dependency array
return null;
}
Loading
Loading