Skip to content

Commit b069255

Browse files
HoonBaekbang9
andauthored
refactor: Renew the storybook (#1074)
[CLNP-2534](https://sendbird.atlassian.net/browse/CLNP-2534) We use **React & Vite** for **storybook**. ### What has been done * Bump up storybook version from v6 to v8 * Clean up the storybook stories * Explain properties under the each module and component [CLNP-2534]: https://sendbird.atlassian.net/browse/CLNP-2534?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: bang9 <gusrn1423@naver.com>
1 parent 33f84d1 commit b069255

File tree

140 files changed

+4462
-14932
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+4462
-14932
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ __snapshots__/**/*
99
*.spec.js.snap
1010
*.spec.tsx.snap
1111

12-
*.stories.js
12+
src/stories/**
1313

1414
*.css
1515
*.scss

.eslintrc.js

Lines changed: 95 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,59 @@
11
module.exports = {
2+
root: true,
3+
globals: {
4+
JSX: true,
5+
React: true,
6+
ChildNode: true,
7+
ReactElement: true,
8+
globalThis: true,
9+
Locale: true,
10+
SendBird: true,
11+
},
212
env: {
313
browser: true,
414
es6: true,
15+
jest: true,
516
},
6-
ignorePatterns: ['**/*.ts', '**/*.tsx', 'node_modules', 'src/legacy'],
7-
extends: [
8-
'plugin:react/recommended',
9-
'airbnb',
10-
],
11-
globals: {
12-
Atomics: 'readonly',
13-
SharedArrayBuffer: 'readonly',
14-
},
15-
parser: '@babel/eslint-parser',
17+
parser: '@typescript-eslint/parser',
1618
parserOptions: {
19+
ecmaVersion: 2020,
20+
sourceType: 'module',
1721
ecmaFeatures: {
1822
jsx: true,
1923
},
20-
ecmaVersion: 2018,
21-
sourceType: 'module',
2224
},
23-
plugins: ['react', 'babel', '@typescript-eslint'],
25+
settings: {
26+
react: {
27+
version: 'detect',
28+
},
29+
'import/resolver': {
30+
node: {
31+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
32+
},
33+
},
34+
},
2435
rules: {
25-
// uncomment 'linebreak-style' to build in windows - its not adviced to commit from windows
26-
// read more - https://community.perforce.com/s/article/3096
27-
// ['linebreak-style']: 0,
36+
'no-unused-expressions': 'off',
37+
'no-await-in-loop': 'off',
38+
// Not to make ESLint complains a type is only being used as type but recognized as a unused variable
39+
// https://stackoverflow.com/questions/57802057/eslint-configuring-no-unused-vars-for-typescript
40+
'no-unused-vars': 'off', // or '@typescript-eslint/no-unused-vars': 'off',
41+
'unused-imports/no-unused-imports': 'error',
42+
'unused-imports/no-unused-vars': [
43+
'warn',
44+
{
45+
vars: 'all',
46+
varsIgnorePattern: '^_',
47+
args: 'after-used',
48+
argsIgnorePattern: '^_',
49+
},
50+
],
51+
'@typescript-eslint/ban-ts-comment': 'off',
52+
'@typescript-eslint/no-explicit-any': 'off',
53+
'@typescript-eslint/no-unused-expressions': 'error',
54+
'react/display-name': 'off',
55+
'react/function-component-definition': 'off',
56+
'react/prop-types': 'off',
2857
'import/extensions': [
2958
'error',
3059
'ignorePackages',
@@ -35,16 +64,55 @@ module.exports = {
3564
tsx: 'never',
3665
},
3766
],
38-
// we don't want to force to define function component only
39-
'react/function-component-definition': 'off',
40-
'no-unused-expressions': 'off',
41-
'@typescript-eslint/no-unused-expressions': ['error'],
42-
},
43-
settings: {
44-
'import/resolver': {
45-
node: {
46-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
47-
},
48-
},
67+
// TODO(Ahyoung): fix and remove one by one
68+
'no-shadow': 'off',
69+
'no-else-return': 'off',
70+
'no-param-reassign': 'off',
71+
'no-useless-escape': 'off',
72+
'no-underscore-dangle': 'off',
73+
'no-confusing-arrow': 'off',
74+
'no-mixed-operators': 'off',
75+
'no-nested-ternary': 'off',
76+
'no-unneeded-ternary': 'off',
77+
'no-use-before-define': 'off',
78+
'no-cond-assign': 'off',
79+
'no-plusplus': 'off',
80+
'no-bitwise': 'off',
81+
'no-restricted-syntax': 'off',
82+
'no-prototype-builtins': 'off',
83+
'import/no-unresolved': 'off',
84+
'import/no-extraneous-dependencies': 'off',
85+
'import/no-useless-path-segments': 'off',
86+
'import/prefer-default-export': 'off',
87+
'import/order': 'off',
88+
'import/no-named-as-default-member': 'off',
89+
'object-curly-newline': 'off',
90+
'object-shorthand': 'off',
91+
'consistent-return': 'off',
92+
'max-len': 'off',
93+
'arrow-body-style': 'off',
94+
'function-paren-newline': 'off',
95+
'prefer-template': 'off',
96+
'padded-blocks': 'off',
97+
'arrow-parens': 'off',
98+
'dot-notation': 'off',
99+
camelcase: 'off',
100+
radix: 'off',
101+
'prefer-destructuring': 'off',
102+
'default-case': 'off',
103+
curly: 'off',
104+
yoda: 'off',
105+
'brace-style': 'off',
106+
'nonblock-statement-body-position': 'off',
107+
'func-names': 'off',
108+
// In some cases, eslint requires semicolon and wants it removed at the same time
109+
// https://stackoverflow.com/questions/58474874/eslint-demands-semicolon-and-wants-it-removed-at-the-same-time
110+
semi: 'off',
111+
'@typescript-eslint/semi': ['error'],
112+
'object-curly-spacing': ['error', 'always'],
113+
quotes: ['error', 'single'],
49114
},
115+
extends: ['plugin:react/recommended', 'plugin:@typescript-eslint/recommended', 'airbnb-base'],
116+
plugins: ['react', '@typescript-eslint', 'unused-imports'],
117+
ignorePatterns: ['node_modules', 'ui/QuoteMessageInput/mockMessage.ts'],
50118
};

.eslintrc.json

Lines changed: 0 additions & 127 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Workflow name
2+
name: Build and Publish Storybook to GitHub Pages
3+
4+
on:
5+
# Event for the workflow to run on
6+
push:
7+
branches:
8+
- 'main'
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
# List of jobs
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
# Job steps
20+
steps:
21+
# Manual Checkout
22+
- uses: actions/checkout@v4
23+
24+
# Set up Node
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: '18.x'
28+
29+
#👇 Add Storybook build and deploy to GitHub Pages as a step in the workflow
30+
- uses: bitovi/github-actions-storybook-to-github-pages@v1.0.3
31+
with:
32+
install_command: yarn install # default: npm ci
33+
build_command: yarn build-storybook # default: npm run build-storybook
34+
path: storybook-static # default: dist/storybook
35+
checkout: false # default: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ yarn-debug.log*
3535
yarn-error.log*
3636

3737
.idea/
38+
39+
*storybook.log

.storybook/main.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

.storybook/main.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { mergeConfig } from 'vite';
2+
import svgr from 'vite-plugin-svgr';
3+
import { dirname, join } from 'path';
4+
5+
/**
6+
* This function is used to resolve the absolute path of a package.
7+
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
8+
*/
9+
function getAbsolutePath(value: string): any {
10+
return dirname(require.resolve(join(value, 'package.json')));
11+
}
12+
13+
export default {
14+
stories: ['../src/stories/**/*.mdx', '../src/stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
15+
addons: [getAbsolutePath('@storybook/addon-essentials')],
16+
framework: {
17+
name: getAbsolutePath('@storybook/react-vite'),
18+
options: {},
19+
},
20+
viteFinal: (config) => {
21+
return mergeConfig(config, {
22+
plugins: [svgr({ include: '**/*.svg' })],
23+
});
24+
},
25+
};

0 commit comments

Comments
 (0)