Skip to content

Commit 4097bac

Browse files
committed
add Vite
1 parent fd4d62d commit 4097bac

10 files changed

+7296
-13138
lines changed

.eslintrc.cjs

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2024: true,
5+
},
6+
extends: [
7+
'standard',
8+
'plugin:react/recommended',
9+
'airbnb',
10+
'plugin:prettier/recommended',
11+
'plugin:cypress/recommended',
12+
],
13+
parserOptions: {
14+
ecmaFeatures: {
15+
jsx: true,
16+
},
17+
ecmaVersion: 'latest',
18+
sourceType: 'module',
19+
},
20+
plugins: ['jsx-a11y', 'import', 'react', 'prettier'],
21+
rules: {
22+
'function-paren-newline': ['error', 'consistent'],
23+
'comma-dangle': [
24+
'error',
25+
{
26+
arrays: 'always-multiline',
27+
objects: 'always-multiline',
28+
imports: 'always-multiline',
29+
exports: 'always-multiline',
30+
functions: 'always-multiline',
31+
},
32+
],
33+
indent: [
34+
'error',
35+
2,
36+
{
37+
SwitchCase: 1,
38+
VariableDeclarator: 1,
39+
outerIIFEBody: 1,
40+
// MemberExpression: null,
41+
FunctionDeclaration: {
42+
parameters: 1,
43+
body: 1,
44+
},
45+
FunctionExpression: {
46+
parameters: 1,
47+
body: 1,
48+
},
49+
CallExpression: {
50+
arguments: 1,
51+
},
52+
ArrayExpression: 1,
53+
ObjectExpression: 1,
54+
ImportDeclaration: 1,
55+
flatTernaryExpressions: false,
56+
// list derived from https://github.com/benjamn/ast-types/blob/HEAD/def/jsx.js
57+
ignoredNodes: [
58+
'JSXElement',
59+
'JSXElement > *',
60+
'JSXAttribute',
61+
'JSXIdentifier',
62+
'JSXNamespacedName',
63+
'JSXMemberExpression',
64+
'JSXSpreadAttribute',
65+
'JSXExpressionContainer',
66+
'JSXOpeningElement',
67+
'JSXClosingElement',
68+
'JSXFragment',
69+
'JSXOpeningFragment',
70+
'JSXClosingFragment',
71+
'JSXText',
72+
'JSXEmptyExpression',
73+
'JSXSpreadChild',
74+
],
75+
ignoreComments: false,
76+
},
77+
],
78+
'no-unused-expressions': [
79+
'error',
80+
{
81+
allowShortCircuit: false,
82+
allowTernary: false,
83+
allowTaggedTemplates: false,
84+
},
85+
],
86+
'jsx-a11y/label-has-for': [
87+
2,
88+
{
89+
components: ['Label'],
90+
required: {
91+
some: ['id', 'nesting'],
92+
},
93+
allowChildren: true,
94+
},
95+
],
96+
'jsx-a11y/label-has-associated-control': [2, { assert: 'either' }],
97+
'jsx-a11y/control-has-associated-label': 'off',
98+
'implicit-arrow-linebreak': 0,
99+
'import/prefer-default-export': 0,
100+
'import/no-extraneous-dependencies': [
101+
'error',
102+
{
103+
devDependencies: true,
104+
optionalDependencies: false,
105+
peerDependencies: false,
106+
},
107+
],
108+
'max-len': [
109+
'error',
110+
{
111+
ignoreTemplateLiterals: true,
112+
ignoreComments: true,
113+
},
114+
],
115+
'no-console': 'error',
116+
'no-param-reassign': [2, { props: true }],
117+
'no-shadow': ['error', { builtinGlobals: false }],
118+
'padding-line-between-statements': [
119+
'error',
120+
{ blankLine: 'always', prev: '*', next: 'return' },
121+
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
122+
{
123+
blankLine: 'any',
124+
prev: ['const', 'let', 'var'],
125+
next: ['const', 'let', 'var'],
126+
},
127+
{ blankLine: 'always', prev: 'directive', next: '*' },
128+
{ blankLine: 'always', prev: 'block-like', next: '*' },
129+
],
130+
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
131+
'react/prop-types': 0,
132+
'react/react-in-jsx-scope': 0,
133+
'react/destructuring-assignment': 0,
134+
'react/function-component-definition': 0,
135+
},
136+
};

.eslintrc.js

-4
This file was deleted.

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
node-version: [14.x]
14+
node-version: [20.x]
1515

1616
steps:
1717
- uses: actions/checkout@v2

.github/workflows/test.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
node-version: [14.x]
14+
node-version: [20.x]
1515

1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Use Node.js ${{ matrix.node-version }}
1919
uses: actions/setup-node@v1
2020
with:
2121
node-version: ${{ matrix.node-version }}
22+
# fix rollup issue
23+
- run: rm -rf node_modules package-lock.json
2224
- run: npm install
2325
- run: npm test -- -l
2426
- name: Upload tests report(cypress mochaawesome merged HTML report)

cypress.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ module.exports = defineConfig({
1919
component: {
2020
specPattern: 'src/**/*.spec.{js,ts,jsx,tsx}',
2121
devServer: {
22-
framework: 'create-react-app',
23-
bundler: 'webpack',
22+
framework: 'react',
23+
bundler: 'vite',
2424
},
2525
},
2626
});

index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Vite + React + TS</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/index.jsx"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)