Skip to content

Commit 0d7c3c3

Browse files
author
姚观寿
committed
eslint 校验
1 parent 5c43a4c commit 0d7c3c3

Some content is hidden

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

53 files changed

+5206
-5205
lines changed

.eslintrc.js

+72-59
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,83 @@
22
* @Date: 2022-05-09 11:13:39
33
* @Author: Yao guan shou
44
* @LastEditors: Yao guan shou
5-
* @LastEditTime: 2022-07-04 12:57:04
6-
* @FilePath: /webpack-cli/.eslintrc.js
5+
* @LastEditTime: 2022-08-10 19:46:16
6+
* @FilePath: /react-loading-ssr/.eslintrc.js
77
* @Description:
88
*/
99
//配置: https://eslint.bootcss.com/
1010
module.exports = {
11-
root: true, // 当前项目使用这个配置文件, 不会往父级目录找.eslintrc.js文件
11+
root: true, // 当前项目使用这个配置文件, 不会往父级目录找.eslintrc.js文件
1212

13-
env: {
14-
// 指定eslint启动环境(node支持), browser: true也可以在浏览器设置
15-
node: true,
16-
commonjs: true,
17-
amd: true,
18-
es6: true,
19-
mocha: true,
20-
browser: true,
21-
es2021: true,
22-
},
23-
plugins: ['react', 'jsx-a11y', 'import', '@babel'],
24-
parser: '@babel/eslint-parser',
25-
parserOptions: {
26-
requireConfigFile: false,
27-
// parser: "@babel/eslint-parser",
28-
ecmaVersion: 6,
29-
sourceType: 'module',
30-
ecmaFeatures: {
31-
jsx: true,
32-
modules: true,
33-
experimentalObjectRestSpread: true,
34-
},
13+
env: {
14+
// 指定eslint启动环境(node支持), browser: true也可以在浏览器设置
15+
node: true,
16+
commonjs: true,
17+
amd: true,
18+
es6: true,
19+
mocha: true,
20+
browser: true,
21+
es2021: true,
22+
},
23+
plugins: [
24+
'react',
25+
'jsx-a11y',
26+
'import',
27+
'@babel',
28+
29+
// 'prettier'
30+
],
31+
parser: '@babel/eslint-parser',
32+
parserOptions: {
33+
requireConfigFile: false,
34+
// parser: "@babel/eslint-parser",
35+
ecmaVersion: 6,
36+
sourceType: 'module',
37+
ecmaFeatures: {
38+
jsx: true,
39+
modules: true,
40+
experimentalObjectRestSpread: true,
3541
},
36-
extends: ['eslint:recommended', 'plugin:react/recommended'],
42+
},
3743

38-
settings: { react: { pragma: 'React', version: '15.6.1' } },
44+
extends: [
45+
'eslint:recommended',
46+
'plugin:react/recommended',
47+
// 'prettier',
48+
'plugin:prettier/recommended',
49+
],
3950

40-
// 这里可以进行自定义规则配置
41-
// key:规则代号
42-
// value:具体的限定方式
43-
// "off" or 0 - 关闭规则
44-
// "warn" or 1 - 将规则视为一个警告(不会影响退出码),只警告,不会退出程序
45-
// "error" or 2 - 将规则视为一个错误 (退出码为1),报错并退出程序
46-
rules: {
47-
'no-debugger': 0,
48-
'react/prop-types': 0,
49-
'no-prototype-builtins': 0,
50-
'comma-dangle': 0,
51-
'react/jsx-uses-vars': 1,
52-
'react/display-name': 1,
53-
'no-unused-vars': 'warn',
54-
'no-console': 'warn',
55-
'no-unexpected-multiline': 'warn',
56-
// // 自定义规则 - 其实上面集成后有很多内置的规则, 这里可以进行规则的一些修改
57-
// 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', // 上线环境用打印就报警告, 开发环境关闭此规则
58-
// 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', // debugger可以终止代码执行
59-
// 'no-multiple-empty-lines': 'off', // 不允许有连续多行空行(关闭规则)
60-
// 'no-undef': 1, //不能有未定义的变量
61-
eqeqeq: ['error', 'always'],
62-
// 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
63-
'no-undef': 'error',
64-
// 'no-void': 2, //禁用void操作符
65-
'@babel/new-cap': 'error',
66-
'@babel/no-invalid-this': 'error',
67-
'@babel/no-unused-expressions': 'error',
68-
'@babel/object-curly-spacing': 'error',
69-
'@babel/semi': 'error',
70-
},
71-
};
51+
settings: { react: { pragma: 'React', version: '15.6.1' } },
52+
53+
// 这里可以进行自定义规则配置
54+
// key:规则代号
55+
// value:具体的限定方式
56+
// "off" or 0 - 关闭规则
57+
// "warn" or 1 - 将规则视为一个警告(不会影响退出码),只警告,不会退出程序
58+
// "error" or 2 - 将规则视为一个错误 (退出码为1),报错并退出程序
59+
rules: {
60+
'no-debugger': 0,
61+
'react/prop-types': 0,
62+
'no-prototype-builtins': 0,
63+
'comma-dangle': 0,
64+
'react/jsx-uses-vars': 1,
65+
'react/display-name': 1,
66+
'no-unused-vars': 'warn',
67+
'no-console': 'warn',
68+
'no-unexpected-multiline': 'warn',
69+
// // 自定义规则 - 其实上面集成后有很多内置的规则, 这里可以进行规则的一些修改
70+
// 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', // 上线环境用打印就报警告, 开发环境关闭此规则
71+
// 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', // debugger可以终止代码执行
72+
// 'no-multiple-empty-lines': 'off', // 不允许有连续多行空行(关闭规则)
73+
// 'no-undef': 1, //不能有未定义的变量
74+
eqeqeq: ['error', 'always'],
75+
// 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
76+
'no-undef': 'error',
77+
// 'no-void': 2, //禁用void操作符
78+
'@babel/new-cap': 'error',
79+
'@babel/no-invalid-this': 'error',
80+
'@babel/no-unused-expressions': 'error',
81+
'@babel/object-curly-spacing': 'error',
82+
'@babel/semi': 'error',
83+
},
84+
}

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ignore artifacts:
2+
build
3+
coverage
4+
5+
# Ignore all HTML files:
6+
*.html

.prettierrc.js

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* @Date: 2022-08-10 18:46:38
3+
* @Author: Yao guan shou
4+
* @LastEditors: Yao guan shou
5+
* @LastEditTime: 2022-08-10 19:45:14
6+
* @FilePath: /react-loading-ssr/.prettierrc.js
7+
* @Description:
8+
*/
9+
module.exports = {
10+
'prettier/prettier': [
11+
'error',
12+
{
13+
singleQuote: true,
14+
parser: 'flow',
15+
},
16+
],
17+
singleQuote: false, // 使用单引号
18+
jsxSingleQuote: false, // jsx中使用单引号
19+
// semi: false, // 不加分号
20+
// trailingComma: 'none', // 结尾处不加逗号
21+
// htmlWhitespaceSensitivity: 'ignore', // 忽略'>'下落问题
22+
// printWidth: 1800, //单行长度
23+
// tabWidth: 1000, //缩进长度
24+
// useTabs: false, //使用空格代替tab缩进
25+
// semi: true, //句末使用分号
26+
// singleQuote: true, //使用单引号
27+
// quoteProps: 'as-needed', //仅在必需时为对象的key添加引号
28+
29+
// trailingComma: 'all', //多行时尽可能打印尾随逗号
30+
// bracketSpacing: true, //在对象前后添加空格
31+
// jsxBracketSameLine: true, //多属性html标签的‘>’折行放置
32+
// arrowParens: 'always', //单参数箭头函数参数周围使用圆括号
33+
// requirePragma: false, //无需顶部注释即可格式化
34+
// insertPragma: false, //在已被preitter格式化的文件顶部加上标注
35+
// htmlWhitespaceSensitivity: 'ignore', //对HTML全局空白不敏感
36+
// vueIndentScriptAndStyle: false, //不对vue中的script及style标签缩进
37+
// endOfLine: 'lf', //结束行形式
38+
// embeddedLanguageFormatting: 'auto', //对引用代码进行格式化
39+
// 'prettier.proseWrap': 'preserve', // 是否要换行
40+
// 'vetur.format.defaultFormatter.js': 'prettier', // vetur 使用 prettier格式化代码
41+
// 'prettier.printWidth': 30, // 超过最大值换行
42+
43+
// 'prettier.tabWidth': 2, // 缩进字节数
44+
45+
// 'prettier.useTabs': false, // 缩进不使用tab,使用空格
46+
47+
// 'prettier.semi': false, // 句尾添加分号
48+
49+
// 'prettier.singleQuote': false, // 使用单引号代替双引号
50+
51+
// 'prettier.proseWrap': 'preserve', // 默认值。因为使用了一些折行敏感型的渲染器(如GitHub comment)而按照markdown文本样式进行折行
52+
53+
// 'prettier.arrowParens': 'avoid', // (x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号
54+
55+
// 'prettier.bracketSpacing': true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }"
56+
57+
// 'prettier.endOfLine': 'auto', // 结尾是 \n \r \n\r auto
58+
59+
// 'prettier.eslintIntegration': false, //不让prettier使用eslint的代码格式进行校验
60+
61+
// 'prettier.htmlWhitespaceSensitivity': 'ignore',
62+
63+
// 'prettier.ignorePath': '.prettierignore', // 不使用prettier格式化的文件填写在项目的.prettierignore文件中
64+
65+
// 'prettier.jsxBracketSameLine': false, // 在jsx中把'>' 单独放一行
66+
67+
// 'prettier.jsxSingleQuote': false, // 在jsx中使用单引号代替双引号
68+
69+
// 'prettier.parser': 'babylon', // 格式化的解析器,默认是babylon
70+
71+
// 'prettier.requireConfig': false, // Require a 'prettierconfig' to format prettier
72+
73+
// 'prettier.stylelintIntegration': false, //不让prettier使用stylelint的代码格式进行校验
74+
75+
// 'prettier.trailingComma': 'es5', // 在对象或数组最后一个元素后面是否加逗号(在ES5中加尾逗号)
76+
77+
// 'prettier.tslintIntegration': false, // 不让prettier使用tslint的代码格式进行校验
78+
}

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"workbench.settings.editor": "json",
3+
"workbench.settings.openDefaultSettings": true,
4+
"workbench.settings.useSplitJSON": true
5+
}

client/App/App.js

+26-17
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,36 @@
22
* @Date: 2022-08-05 09:22:30
33
* @Author: Yao guan shou
44
* @LastEditors: Yao guan shou
5-
* @LastEditTime: 2022-08-05 12:04:15
5+
* @LastEditTime: 2022-08-10 19:29:52
66
* @FilePath: /react-loading-ssr/client/App/App.js
7-
* @Description:
7+
* @Description:
88
*/
9-
import React, {Component} from 'react';
10-
import PropTypes from 'prop-types';
11-
import {Provider} from 'react-redux';
12-
import Routers from '@/router';
13-
import './App.less';
14-
import '@/assets/css/base.less';
15-
import 'bootstrap/dist/css/bootstrap.css';
16-
17-
9+
import React, {Component} from "react";
10+
import PropTypes from "prop-types";
11+
import {Provider} from "react-redux";
12+
import Routers from "@/router";
13+
import "./App.less";
14+
import "@/assets/css/base.less";
15+
import "bootstrap/dist/css/bootstrap.css";
1816

1917
const App = (props) => {
20-
const {history, location, store} = props;
21-
return (
22-
<Provider store={store}>
23-
<Routers history={history} location={location} />
24-
</Provider>
25-
);
18+
const {
19+
history,
20+
location,
21+
store,
22+
a,
23+
b,
24+
c,
25+
d,
26+
e,
27+
f,
28+
sadfasdfasdfsadfasdfasdfasdfasdfsdf,
29+
} = props;
30+
return (
31+
<Provider store={store}>
32+
<Routers history={history} location={location} />
33+
</Provider>
34+
);
2635
};
2736
// App.propTypes = {
2837
// location: PropTypes.string,

client/App/CreateApp.js

+30-23
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
1-
import React, {Component} from 'react';
2-
import Loadable, {Capture} from '@/component/Loadable';
3-
import PropTypes from 'prop-types';
4-
import App from './App.js';
5-
import './App.less';
1+
/*
2+
* @Date: 2022-08-09 09:35:04
3+
* @Author: Yao guan shou
4+
* @LastEditors: Yao guan shou
5+
* @LastEditTime: 2022-08-10 18:28:02
6+
* @FilePath: /react-loading-ssr/client/App/CreateApp.js
7+
* @Description:
8+
*/
9+
import React, {Component} from "react";
10+
import Loadable, {Capture} from "@/component/Loadable";
11+
import PropTypes from "prop-types";
12+
import App from "./App.js";
13+
import "./App.less";
614

715
let {
8-
NODE_ENV, // 环境参数
9-
WEB_ENV, // 环境参数
10-
target, // 环境参数
11-
htmlWebpackPluginOptions = '',
16+
NODE_ENV, // 环境参数
17+
WEB_ENV, // 环境参数
18+
target, // 环境参数
19+
htmlWebpackPluginOptions = "",
1220
} = process.env; // 环境参数
1321

14-
1522
const CreateApp = (props = {}) => {
16-
const {modules = []} = props;
23+
const {modules = []} = props;
1724

18-
return target === 'ssr' ? (
19-
<Capture
20-
report={(moduleName) => {
21-
return modules.push(moduleName);
22-
}}
23-
>
24-
<App {...props} />
25-
</Capture>
26-
) : (
27-
<App {...props} />
28-
);
25+
return target === "ssr" ? (
26+
<Capture
27+
report={(moduleName) => {
28+
return modules.push(moduleName);
29+
}}
30+
>
31+
<App {...props} />
32+
</Capture>
33+
) : (
34+
<App {...props} />
35+
);
2936
};
3037

3138
CreateApp.propTypes = {
32-
modules: PropTypes.object,
39+
modules: PropTypes.object,
3340
};
3441
export default CreateApp;

client/App/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import CreateApp from './CreateApp';
1+
import CreateApp from "./CreateApp";
22

33
export default CreateApp;

0 commit comments

Comments
 (0)