Skip to content

Commit 9dea75d

Browse files
author
Fay
committed
init boilerplate
1 parent 3cbe7be commit 9dea75d

Some content is hidden

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

49 files changed

+15757
-0
lines changed

.babelrc.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { argv } = require('yargs')
2+
3+
const getArgs = (key) => {
4+
const arg = argv[key]
5+
if (!arg) return []
6+
return typeof arg === 'string' ? [arg] : arg
7+
}
8+
9+
const env = getArgs('env')
10+
const isDev = env.includes('mode=development')
11+
12+
const babelConfig = {
13+
presets: [
14+
// [
15+
// '@babel/preset-env',
16+
// {
17+
// targets: {
18+
// browsers: ['>1%', 'last 4 versions', 'not ie < 9'],
19+
// },
20+
// useBuiltIns: 'usage',
21+
// debug: false,
22+
// corejs: 3,
23+
// },
24+
// ],
25+
'@babel/preset-react',
26+
],
27+
plugins: [
28+
'@babel/plugin-syntax-dynamic-import',
29+
'@babel/plugin-proposal-class-properties',
30+
'@babel/plugin-proposal-export-namespace-from',
31+
'@babel/plugin-proposal-throw-expressions',
32+
'@babel/proposal-object-rest-spread',
33+
isDev && 'react-refresh/babel',
34+
].filter(Boolean),
35+
}
36+
37+
module.exports = babelConfig

.env.development

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
NODE_ENV=development
2+
PROTOCOL=http
3+
HOST=0.0.0.0
4+
PORT=3000
5+
PUBLIC_URL=/

.env.production

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NODE_ENV=production
2+
PROTOCOL=https

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
webpack

.eslintrc.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const eslintConfig = {
2+
parser: '@typescript-eslint/parser',
3+
plugins: ['@typescript-eslint', 'react'],
4+
env: {
5+
browser: true,
6+
jest: true,
7+
},
8+
extends: [
9+
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
10+
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
11+
'prettier/react', // disables react-specific linting rules that conflict with prettier
12+
],
13+
parserOptions: {
14+
ecmaVersion: 2020,
15+
sourceType: 'module',
16+
ecmaFeatures: {
17+
jsx: true,
18+
},
19+
},
20+
rules: {
21+
'@typescript-eslint/no-unused-vars': 'off',
22+
'@typescript-eslint/no-empty-function': 'off',
23+
'@typescript-eslint/explicit-function-return-type': 'off',
24+
'react/jsx-filename-extension': [
25+
'error',
26+
{
27+
extensions: ['.jsx', '.tsx'],
28+
},
29+
],
30+
},
31+
settings: {
32+
react: {
33+
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
34+
},
35+
},
36+
}
37+
38+
module.exports = eslintConfig

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/dist
11+
12+
# misc
13+
.DS_Store
14+
15+
npm-debug.log*
16+
yarn-debug.log*
17+
yarn-error.log*

.npmrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
registry=https://registry.npm.taobao.org
2+
disturl=https://npm.taobao.org/dist
3+
sass_binary_site=https://npm.taobao.org/mirrors/node-sass
4+
fse_binary_host_mirror=https://npm.taobao.org/mirrors/fsevents

jest.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const jestConfig = {
2+
roots: ['<rootDir>/src'],
3+
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],
4+
setupFiles: ['react-app-polyfill/jsdom'],
5+
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
6+
testMatch: [
7+
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
8+
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
9+
],
10+
testEnvironment: 'jsdom',
11+
transform: {
12+
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': '<rootDir>/node_modules/babel-jest',
13+
},
14+
}
15+
16+
export default jestConfig

0 commit comments

Comments
 (0)