Skip to content

Commit

Permalink
chore: configure the project basic environment
Browse files Browse the repository at this point in the history
  • Loading branch information
xyy94813 committed Jul 1, 2020
1 parent 5b4d936 commit 7c2a92a
Show file tree
Hide file tree
Showing 8 changed files with 17,029 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/

coverage/

# output dir
es/**
lib/**
build/**
dist/**
38 changes: 38 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
env: {
browser: true,
es2020: true,
},
extends: ['plugin:react/recommended', 'airbnb'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 11,
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint'],
rules: {
'import/extensions': ['error', 'never'],
'import/no-extraneous-dependencies': ['error', { peerDependencies: true }],
},
overrides: [
{
files: ['*.ts', '*.tsx'],
rules: {
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
'react/jsx-filename-extension': ['error', { extensions: ['.ts', '.tsx', '.js', '.jsx'] }],
},
},
],
settings: {
'import/resolver': {
/**
* why use this see issue:
* https://github.com/benmosher/eslint-plugin-import/issues/1485
*/
typescript: {}, // this loads <rootdir>/tsconfig.json to eslint
},
},
};
24 changes: 24 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
stories: ['../src/**/*.stories.tsx', '../stories/**/*.stories.tsx', '../stories/**/*.stories.js'],
addons: ['@storybook/addon-actions', '@storybook/addon-links'],
/**
* storybook with typescript
* see https://storybook.js.org/docs/configurations/typescript-config/
*/
webpackFinal: async (config) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve('ts-loader'),
},
// Optional
{
loader: require.resolve('react-docgen-typescript-loader'),
},
],
});
config.resolve.extensions.unshift('.ts', '.tsx');
return config;
},
};
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
transform: {
'.(ts|tsx)': 'ts-jest',
},
testPathIgnorePatterns: ['/node_modules/', '/lib/'],
testRegex: '(/test/.*|\\.(test|spec))\\.(ts|tsx|js)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
};
6 changes: 6 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
'*.{ts,tsx,js,jsx}': [
'./node_modules/.bin/eslint -c .eslintrc.js "src/**/*.{ts,tsx,js,jsx}" --fix',
'git add',
],
};
Loading

0 comments on commit 7c2a92a

Please sign in to comment.