Skip to content
This repository was archived by the owner on May 7, 2022. It is now read-only.

Commit dc8d001

Browse files
committed
开启eslint
1 parent ec3ea52 commit dc8d001

File tree

9 files changed

+149
-134
lines changed

9 files changed

+149
-134
lines changed

.eslintrc

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"extends": [
3+
"eslint:recommended"
4+
],
5+
"plugins": [
6+
"react"
7+
],
8+
"globals": {
9+
"$": true
10+
},
11+
"parser": "babel-eslint",
12+
"parserOptions": {
13+
"ecmaVersion": 6,
14+
"sourceType": "module",
15+
"ecmaFeatures": {
16+
"jsx": true,
17+
"globalReturn": true,
18+
"impliedStrict": true,
19+
"experimentalObjectRestSpread": true,
20+
"arrowFunctions": true,
21+
"modules": true
22+
}
23+
},
24+
"env": {
25+
"es6": true,
26+
"browser": true,
27+
"node": true,
28+
"jquery": true,
29+
"mocha": true
30+
},
31+
"settings": {
32+
"import/ignore": [
33+
"node_modules"
34+
]
35+
},
36+
"ecmaFeatures": {
37+
"jsx": true,
38+
"experimentalObjectRestSpread": true,
39+
"modules": true
40+
},
41+
"rules": {
42+
"quotes": [2, "single"], //单引号
43+
"no-console": 0, //不禁用console
44+
"no-debugger": 2, //禁用debugger
45+
"no-var": 0, //对var警告
46+
"semi": 0, //不强制使用分号
47+
"no-irregular-whitespace": 0, //不规则的空白不允许
48+
"no-trailing-spaces": 1, //一行结束后面有空格就发出警告
49+
"eol-last": 0, //文件以单一的换行符结束
50+
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}], //不能有声明后未被使用的变量或参数
51+
"no-underscore-dangle": 0, //标识符不能以_开头或结尾
52+
"no-alert": 2, //禁止使用alert confirm prompt
53+
"no-lone-blocks": 0, //禁止不必要的嵌套块
54+
"no-class-assign": 2, //禁止给类赋值
55+
"no-cond-assign": 2, //禁止在条件表达式中使用赋值语句
56+
"no-const-assign": 2, //禁止修改const声明的变量
57+
"no-delete-var": 2, //不能对var声明的变量使用delete操作符
58+
"no-dupe-keys": 2, //在创建对象字面量时不允许键重复
59+
"no-duplicate-case": 2, //switch中的case标签不能重复
60+
"no-dupe-args": 2, //函数参数不能重复
61+
"no-empty": 2, //块语句中的内容不能为空
62+
"no-func-assign": 2, //禁止重复的函数声明
63+
"no-invalid-this": 0, //禁止无效的this,只能用在构造器,类,对象字面量
64+
"no-redeclare": 2, //禁止重复声明变量
65+
"no-spaced-func": 2, //函数调用时 函数名与()之间不能有空格
66+
"no-this-before-super": 0, //在调用super()之前不能使用this或super
67+
"no-undef": 2, //不能有未定义的变量
68+
"no-use-before-define": 2, //未定义前不能使用
69+
"camelcase": 0, //强制驼峰法命名
70+
"jsx-quotes": [2, "prefer-double"], //强制在JSX属性(jsx-quotes)中一致使用双引号
71+
"react/display-name": 0, //防止在React组件定义中丢失displayName
72+
"react/forbid-prop-types": [2, {"forbid": ["any"]}], //禁止某些propTypes
73+
"react/jsx-boolean-value": 2, //在JSX中强制布尔属性符号
74+
"react/jsx-closing-bracket-location": 1, //在JSX中验证右括号位置
75+
"react/jsx-curly-spacing": [2, {"when": "never", "children": true}], //在JSX属性和表达式中加强或禁止大括号内的空格。
76+
"react/jsx-indent-props": [2, 4], //验证JSX中的props缩进
77+
"react/jsx-key": 2, //在数组或迭代器中验证JSX具有key属性
78+
"react/jsx-max-props-per-line": [1, {"maximum": 1}], // 限制JSX中单行上的props的最大数量
79+
"react/jsx-no-bind": 0, //JSX中不允许使用箭头函数和bind
80+
"react/jsx-no-duplicate-props": 2, //防止在JSX中重复的props
81+
"react/jsx-no-literals": 0, //防止使用未包装的JSX字符串
82+
"react/jsx-no-undef": 1, //在JSX中禁止未声明的变量
83+
"react/jsx-pascal-case": 0, //为用户定义的JSX组件强制使用PascalCase
84+
"react/jsx-sort-props": 1, //强化props按字母排序
85+
"react/jsx-uses-react": 1, //防止反应被错误地标记为未使用
86+
"react/jsx-uses-vars": 2, //防止在JSX中使用的变量被错误地标记为未使用
87+
"react/no-danger": 0, //防止使用危险的JSX属性
88+
"react/no-did-mount-set-state": 0, //防止在componentDidMount中使用setState
89+
"react/no-did-update-set-state": 1, //防止在componentDidUpdate中使用setState
90+
"react/no-direct-mutation-state": 2, //防止this.state的直接变异
91+
"react/no-multi-comp": 2, //防止每个文件有多个组件定义
92+
"react/no-set-state": 0, //防止使用setState
93+
"react/no-unknown-property": 2, //防止使用未知的DOM属性
94+
"react/prefer-es6-class": 2, //为React组件强制执行ES5或ES6类
95+
"react/prop-types": 0, //防止在React组件定义中丢失props验证
96+
"react/react-in-jsx-scope": 2, //使用JSX时防止丢失React
97+
"react/self-closing-comp": 0, //防止没有children的组件的额外结束标签
98+
"react/sort-comp": 2, //强制组件方法顺序
99+
"no-extra-boolean-cast": 0, //禁止不必要的bool转换
100+
"react/no-array-index-key": 0, //防止在数组中遍历中使用数组key做索引
101+
"react/no-deprecated": 1, //不使用弃用的方法
102+
"react/jsx-equals-spacing": 2, //在JSX属性中强制或禁止等号周围的空格
103+
"no-unreachable": 1, //不能有无法执行的代码
104+
"comma-dangle": 2, //对象字面量项尾不能有逗号
105+
"no-mixed-spaces-and-tabs": 0, //禁止混用tab和空格
106+
"prefer-arrow-callback": 0, //比较喜欢箭头回调
107+
"arrow-parens": 0, //箭头函数用小括号括起来
108+
"arrow-spacing": 0 //=>的前/后括号
109+
}
110+
}

.eslintrc.js

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

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"devDependencies": {
2020
"babel-cli": "^6.26.0",
2121
"babel-core": "^6.26.0",
22+
"babel-eslint": "^8.0.3",
2223
"babel-loader": "^7.1.2",
2324
"babel-plugin-react-transform": "^2.0.2",
2425
"babel-plugin-transform-decorators-legacy": "^1.3.4",
@@ -35,7 +36,7 @@
3536
"compression": "^1.6.2",
3637
"css-loader": "^0.22.0",
3738
"eslint": "^4.5.0",
38-
"eslint-plugin-react": "^7.3.0",
39+
"eslint-plugin-react": "^7.5.1",
3940
"expect": "^1.12.0",
4041
"express": "^4.15.2",
4142
"extract-text-webpack-plugin": "^2.1.2",

server.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/**
22
* Created by yongyuehuang on 2017/8/22.
33
*/
4-
var webpack = require('webpack')
5-
var WebpackDevServer = require('webpack-dev-server')
6-
var config = require('./webpack.config')
4+
const webpack = require('webpack')
5+
const WebpackDevServer = require('webpack-dev-server')
6+
const config = require('./webpack.config')
77
const errorOverlayMiddleware = require('react-error-overlay/middleware')
88
const webpackServerConfig = require('./webpackServerConfig')
9-
var proxy = require('http-proxy-middleware')
9+
const proxy = require('http-proxy-middleware')
1010

1111
new WebpackDevServer(webpack(config), {
1212
hot: true,
1313
compress: true,
1414
historyApiFallback: true,
1515
publicPath: '/build/',
1616
watchOptions: {
17-
ignored: /node_modules/,
17+
ignored: /node_modules/
1818
},
1919
stats: {
2020
modules: false,
@@ -29,10 +29,9 @@ new WebpackDevServer(webpack(config), {
2929
}))
3030
}
3131
}
32-
}).listen(webpackServerConfig.port, webpackServerConfig.host, function (err, result) {
32+
}).listen(webpackServerConfig.port, webpackServerConfig.host, function (err) {
3333
if (err) {
3434
return console.log(err);
3535
}
36-
3736
console.log(`Listening at http://${webpackServerConfig.host}:${webpackServerConfig.port}/`);
3837
});

src/containers/Commons/MyScroll.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,48 @@ var _react2 = _interopRequireDefault(_react);
1515

1616
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1717

18-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
1919

20-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
20+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called'); } return call && (typeof call === 'object' || typeof call === 'function') ? call : self; }
2121

22-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
22+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
2323

2424
var JRoll = require('jroll');
2525

2626
var MyJRoll = function (_React$Component) {
2727
_inherits(MyJRoll, _React$Component);
28-
28+
2929
function MyJRoll(props) {
3030
_classCallCheck(this, MyJRoll);
31-
31+
3232
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
33-
33+
3434
_this.jroll = null;
3535
return _this;
3636
}
37-
37+
3838
MyJRoll.prototype.componentDidMount = function componentDidMount() {
3939
var wrappers = this.props.ID || 'wrappers';
4040
this.jroll = new JRoll('#' + wrappers);
4141
this.jroll.refresh();
4242
};
43-
43+
4444
MyJRoll.prototype.componentDidUpdate = function componentDidUpdate() {
4545
var _this2 = this;
46-
46+
4747
setTimeout(function () {
4848
return _this2.jroll.refresh();
4949
}, 400);
5050
};
51-
51+
5252
MyJRoll.prototype.render = function render() {
5353
var _props = this.props,
5454
height = _props.height,
5555
maxHeight = _props.maxHeight;
56-
56+
5757
var _style = void 0;
5858
if (!maxHeight) {
59-
_style = { height: height ? height : "100%" };
59+
_style = { height: height ? height : '100%' };
6060
} else {
6161
_style = { maxHeight: maxHeight };
6262
}
@@ -70,7 +70,7 @@ var MyJRoll = function (_React$Component) {
7070
)
7171
);
7272
};
73-
73+
7474
return MyJRoll;
7575
}(_react2.default.Component);
7676

src/containers/Commons/SetDocumentTitle.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,39 @@ var _propTypes2 = _interopRequireDefault(_propTypes);
2929

3030
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3131

32-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
32+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
3333

34-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
34+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called'); } return call && (typeof call === 'object' || typeof call === 'function') ? call : self; }
3535

36-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
36+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
3737

3838
var SetDocumentTitle = function (_React$Component) {
3939
_inherits(SetDocumentTitle, _React$Component);
40-
40+
4141
function SetDocumentTitle() {
4242
_classCallCheck(this, SetDocumentTitle);
43-
43+
4444
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
4545
}
46-
46+
4747
SetDocumentTitle.prototype.setTitle = function setTitle() {
4848
var title = this.props.title;
49-
49+
5050
document.title = title;
5151
};
52-
52+
5353
SetDocumentTitle.prototype.componentDidMount = function componentDidMount() {
5454
this.setTitle();
5555
};
56-
56+
5757
SetDocumentTitle.prototype.componentDidUpdate = function componentDidUpdate() {
5858
this.setTitle();
5959
};
60-
60+
6161
SetDocumentTitle.prototype.render = function render() {
6262
return _react2.default.Children.only(this.props.children);
6363
};
64-
64+
6565
return SetDocumentTitle;
6666
}(_react2.default.Component);
6767

0 commit comments

Comments
 (0)