Skip to content

Commit

Permalink
Merge pull request #592 from pixiv/naporitan/merge-test
Browse files Browse the repository at this point in the history
Merge main to v4.0.0
  • Loading branch information
naporin0624 authored Jul 12, 2024
2 parents 10a0639 + 4abcf9d commit 9a993d6
Show file tree
Hide file tree
Showing 92 changed files with 2,350 additions and 3,882 deletions.
12 changes: 0 additions & 12 deletions .eslintignore

This file was deleted.

72 changes: 0 additions & 72 deletions .eslintrc.js

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ jobs:
- run: yarn install --immutable --inline-builds
- run: yarn build
- name: Test
run: |
yarn test
yarn snapshot
run: yarn test
env:
CI: 'true'

Expand Down
13 changes: 0 additions & 13 deletions .storybook/jest.config.mjs

This file was deleted.

34 changes: 0 additions & 34 deletions .storybook/jest.setup.ts

This file was deleted.

7 changes: 7 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ module.exports = {
],

async webpackFinal(config, { configType }) {
config.resolve.alias = {
...config.resolve.alias,
react: getAbsolutePath('react'),
'react-dom': getAbsolutePath('react-dom'),
'@storybook/react-dom-shim': '@storybook/react-dom-shim',
}

if (configType === 'PRODUCTION') {
return config
}
Expand Down
1 change: 1 addition & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import themeDecorator from './theme-decorator'
import { DocsContainer } from './docs-container'

Expand Down
16 changes: 10 additions & 6 deletions .storybook/storybook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ function getAllStoryFiles() {
.sync(path.join(__dirname, globPatterns))
.filter((filePath) => !ignorePatterns.test(filePath))

return storyFiles.map((filePath) => {
const storyFile = require(filePath)
return { filePath, storyFile }
})
return Promise.all(
storyFiles.map(async (filePath) => {
const storyFile = await import(filePath)

return { filePath, storyFile }
})
)
}

// Recreate similar options to Storyshots. Place your configuration below
Expand All @@ -52,8 +55,9 @@ const options = {
snapshotExtension: 'storyshot',
}

describe(options.suite, () => {
getAllStoryFiles().forEach(({ storyFile, filePath }) => {
describe(options.suite, async () => {
const files = await getAllStoryFiles()
files.forEach(({ storyFile, filePath }) => {
const meta = storyFile.default
const title = meta.title || filePath
const dir = path.join(path.dirname(filePath), options.snapshotsDirName)
Expand Down
8 changes: 0 additions & 8 deletions babel.config.js

This file was deleted.

166 changes: 166 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// @ts-nocheck
import eslint from '@eslint/js'
import _import from 'eslint-plugin-import-x'
import globals from 'globals'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import tseslint from 'typescript-eslint'
import eslintPluginReact from 'eslint-plugin-react'
import eslintPluginReactHook from 'eslint-plugin-react-hooks'
import eslintPluginPrettierRecommended from 'eslint-config-prettier'
import { fixupPluginRules } from '@eslint/compat'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const tseslintConfig = tseslint.config(
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
ecmaVersion: 2018,
sourceType: 'module',
parser: tseslint.parser,
parserOptions: {
ecmaFeatures: { jsx: true },
project: ['./tsconfig.json', 'packages/**/tsconfig.json'],
tsconfigRootDir: __dirname,
},
},
rules: {
'@typescript-eslint/no-empty-function': 'error',
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
},
}
)

const typescriptConfig = [
...tseslintConfig,
{
files: ['**/*.ts', '**/*.tsx'],
plugins: {
'@typescript-eslint': tseslint.plugin,
import: _import,
},
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
],
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'*.config.ts',
'**/*.config.ts',
'**/*.test.ts',
'**/*.test.tsx',
'**/*.story.tsx',
'**/_lib/**',
],
},
],
},
},
{
files: ['**/*.tsx', '**/*.ts'],
languageOptions: {
globals: {
...globals.browser,
},
},
plugins: {
react: eslintPluginReact,
'react-hooks': fixupPluginRules(eslintPluginReactHook),
},
rules: {
...eslintPluginReact.configs.recommended.rules,
...eslintPluginReactHook.configs.recommended.rules,
'react/prop-types': 'off',
'react/no-unknown-property': ['error', { ignore: ['css'] }],
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
},
settings: {
react: {
version: 'detect',
},
},
},
]

const config = [
eslint.configs.recommended,
eslintPluginPrettierRecommended,
...typescriptConfig,
{
ignores: [
'**/dist/',
'**/node_modules/',
'**/__snapshots__/',
'**/.yarn/',
'public/',
'storybook-static/',
'coverage/',
'**/.next/',
'misc/',
'packages/tailwind-diff/bin/tailwind-diff.js',
'packages/icon-files/src/',
'eslint.config.mjs',
'vitest.*',
'.storybook',
],
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'no-console': 'warn',
'no-undef': 'off',
'no-constant-condition': 'error',
},
},
{
files: [
'**/*.test.ts',
'**/*.test.tsx',
'**/__tests__/**',
'**/*.config.*',
'*.config.*',
'**/*.story.*',
'.storybook/**',
],
languageOptions: {
globals: {
...globals.node,
},
},
plugins: {
import: _import,
},
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
{
files: ['**/docs/**'],
plugins: {
import: _import,
},
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
]

export default config
Loading

0 comments on commit 9a993d6

Please sign in to comment.