Skip to content

Commit

Permalink
eslintをv9に
Browse files Browse the repository at this point in the history
  • Loading branch information
NEKOYASAN committed Sep 9, 2024
1 parent 39e59f3 commit 1b72927
Show file tree
Hide file tree
Showing 6 changed files with 312 additions and 488 deletions.
64 changes: 0 additions & 64 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Decorator, Preview } from '@storybook/react';
import '~/main.css';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

export const customDecorator: Decorator = (Story, context) => {
export const customDecorator: Decorator = (Story) => {
const client = new QueryClient({
defaultOptions: {
queries: {
Expand Down
3 changes: 2 additions & 1 deletion .vitest/setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createSerializer } from '@emotion/jest';
import { setProjectAnnotations } from '@storybook/react';

import globalStorybookConfig from '../.storybook/preview';
import { createSerializer } from '@emotion/jest';

setProjectAnnotations([globalStorybookConfig]);

expect.addSnapshotSerializer(createSerializer());
97 changes: 97 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
import unusedImports from 'eslint-plugin-unused-imports';
import eslintPluginImportX from 'eslint-plugin-import-x';
import eslintConfigPrettier from 'eslint-config-prettier';
import vitest from '@vitest/eslint-plugin';

export default tseslint.config(
{ ignores: ['dist', 'coverage'] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
eslintPluginImportX.flatConfigs.recommended,
eslintPluginImportX.flatConfigs.typescript,
eslintConfigPrettier,
],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
'unused-imports': unusedImports,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'@typescript-eslint/no-explicit-any': 'warn',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
'import-x/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
pathGroups: [
{
pattern: '{react,react-dom/**}',
group: 'builtin',
position: 'before',
},
{
pattern: '~/**',
group: 'parent',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
},
settings: {
'import-x/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import-x/resolver': {
typescript: true,
node: true,
},
},
},
{
files: ['**/*.stories.{ts,tsx}'],
rules: {
'react-hooks/rules-of-hooks': 'off',
},
},
{
files: ['**/*.test.{ts,tsx}'], // or any other pattern
plugins: {
vitest,
},
rules: {
...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
'vitest/max-nested-describe': ['error', { max: 3 }], // you can also modify rules' behavior using option like this
},
}
);
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build --stats-json",
Expand All @@ -24,6 +24,7 @@
"@internationalized/number": "3.5.3",
"@maplibre/maplibre-gl-style-spec": "20.3.1",
"@tanstack/react-query": "5.55.4",
"@vitest/eslint-plugin": "1.1.0",
"maplibre-gl": "4.7.0",
"react": "18.3.1",
"react-aria": "3.34.3",
Expand All @@ -35,6 +36,7 @@
"devDependencies": {
"@chromatic-com/storybook": "1.9.0",
"@emotion/jest": "11.13.0",
"@eslint/js": "9.10.0",
"@storybook/addon-essentials": "8.2.9",
"@storybook/addon-interactions": "8.2.9",
"@storybook/addon-links": "8.2.9",
Expand All @@ -55,15 +57,14 @@
"@vitest/ui": "2.0.5",
"chromatic": "11.7.1",
"clsx": "2.1.1",
"eslint": "8.57.0",
"eslint": "9.10.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.3",
"eslint-plugin-import-x": "4.2.1",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-hooks": "5.1.0-rc.0",
"eslint-plugin-react-refresh": "0.4.11",
"eslint-plugin-storybook": "0.8.0",
"eslint-plugin-unused-imports": "4.1.3",
"eslint-plugin-vitest": "0.5.4",
"globals": "15.9.0",
"happy-dom": "15.7.3",
"playwright": "1.47.0",
"plop": "4.0.1",
Expand All @@ -73,6 +74,7 @@
"tailwind-merge": "2.5.2",
"tailwindcss": "4.0.0-alpha.23",
"typescript": "5.5.4",
"typescript-eslint": "8.4.0",
"vite": "5.4.3",
"vitest": "2.0.5"
},
Expand Down
Loading

0 comments on commit 1b72927

Please sign in to comment.