Skip to content

Commit 6b62c8b

Browse files
author
yunkui.zhou
committed
添加eslint
1 parent 730df40 commit 6b62c8b

Some content is hidden

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

62 files changed

+1363
-1245
lines changed

.eslintrc.js

+13-181
Original file line numberDiff line numberDiff line change
@@ -15,194 +15,26 @@ module.exports = {
1515
},
1616

1717
"plugins": [
18-
"babel",
19-
"import",
20-
"node",
21-
"promise",
22-
"standard",
23-
"react"
18+
"react",
19+
"import"
2420
],
2521

2622
"globals": {
2723
"document": false,
2824
"navigator": false,
29-
"window": false
25+
"window": false,
26+
"Image": true
3027
},
3128

3229
"rules": {
33-
"accessor-pairs": "error",
34-
"arrow-spacing": ["error", { "before": true, "after": true }],
35-
"block-spacing": ["error", "always"],
36-
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
37-
"camelcase": ["error", { "properties": "never" }],
38-
"comma-dangle": [0],
39-
"comma-spacing": ["error", { "before": false, "after": true }],
40-
"comma-style": ["error", "last"],
41-
"constructor-super": "error",
42-
"curly": ["error", "multi-line"],
43-
"dot-location": ["error", "property"],
44-
"eol-last": "error",
45-
"eqeqeq": ["error", "always", { "null": "ignore" }],
46-
"func-call-spacing": ["error", "never"],
47-
"generator-star-spacing": ["error", { "before": true, "after": true }],
48-
"handle-callback-err": ["error", "^(err|error)$" ],
49-
"indent": ["error", 2, {
50-
"SwitchCase": 1,
51-
"VariableDeclarator": 1,
52-
"outerIIFEBody": 1,
53-
"MemberExpression": 1,
54-
"FunctionDeclaration": { "parameters": 1, "body": 1 },
55-
"FunctionExpression": { "parameters": 1, "body": 1 },
56-
"CallExpression": { "arguments": 1 },
57-
"ArrayExpression": 1,
58-
"ObjectExpression": 1,
59-
"ImportDeclaration": 1,
60-
"flatTernaryExpressions": false,
61-
"ignoreComments": false
30+
"react/jsx-filename-extension": ["warn", {"extensions": [".js", ".jsx"]}],
31+
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["server/config/development.js"]}],
32+
"react/forbid-prop-types": ["error", {
33+
forbid: [],
34+
checkContextTypes: true,
35+
checkChildContextTypes: true,
6236
}],
63-
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
64-
"keyword-spacing": ["error", { "before": true, "after": true }],
65-
"new-cap": ["error", { "newIsCap": true, "capIsNew": false }],
66-
"new-parens": "error",
67-
"no-array-constructor": "error",
68-
"no-caller": "error",
69-
"no-class-assign": "error",
70-
"no-compare-neg-zero": "error",
71-
"no-cond-assign": "error",
72-
"no-const-assign": "error",
73-
"no-constant-condition": ["error", { "checkLoops": false }],
74-
"no-control-regex": "error",
75-
"no-debugger": "error",
76-
"no-delete-var": "error",
77-
"no-dupe-args": "error",
78-
"no-dupe-class-members": "error",
79-
"no-dupe-keys": "error",
80-
"no-duplicate-case": "error",
81-
"no-empty-character-class": "error",
82-
"no-empty-pattern": "error",
83-
"no-eval": "error",
84-
"no-ex-assign": "error",
85-
"no-extend-native": "error",
86-
"no-extra-bind": "error",
87-
"no-extra-boolean-cast": "error",
88-
"no-extra-parens": ["error", "functions"],
89-
"no-fallthrough": "error",
90-
"no-floating-decimal": "error",
91-
"no-func-assign": "error",
92-
"no-global-assign": "error",
93-
"no-implied-eval": "error",
94-
"no-inner-declarations": ["error", "functions"],
95-
"no-invalid-regexp": "error",
96-
"no-irregular-whitespace": "error",
97-
"no-iterator": "error",
98-
"no-label-var": "error",
99-
"no-labels": ["error", { "allowLoop": false, "allowSwitch": false }],
100-
"no-lone-blocks": "error",
101-
"no-mixed-operators": ["error", {
102-
"groups": [
103-
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
104-
["&&", "||"],
105-
["in", "instanceof"]
106-
],
107-
"allowSamePrecedence": true
108-
}],
109-
"no-mixed-spaces-and-tabs": "error",
110-
"no-multi-spaces": "error",
111-
"no-multi-str": "error",
112-
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }],
113-
"no-negated-in-lhs": "error",
114-
"no-new": "error",
115-
"no-new-func": "error",
116-
"no-new-object": "error",
117-
"no-new-require": "error",
118-
"no-new-symbol": "error",
119-
"no-new-wrappers": "error",
120-
"no-obj-calls": "error",
121-
"no-octal": "error",
122-
"no-octal-escape": "error",
123-
"no-path-concat": "error",
124-
"no-proto": "error",
125-
"no-redeclare": "error",
126-
"no-regex-spaces": "error",
127-
"no-return-assign": ["error", "except-parens"],
128-
"no-return-await": "error",
129-
"no-self-assign": "error",
130-
"no-self-compare": "error",
131-
"no-sequences": "error",
132-
"no-shadow-restricted-names": "error",
133-
"no-sparse-arrays": "error",
134-
"no-tabs": "error",
135-
"no-template-curly-in-string": "error",
136-
"no-this-before-super": "error",
137-
"no-throw-literal": "error",
138-
"no-trailing-spaces": 1,
139-
"no-undef": "error",
140-
"no-undef-init": "error",
141-
"no-unexpected-multiline": "error",
142-
"no-unmodified-loop-condition": "error",
143-
"no-unneeded-ternary": ["error", { "defaultAssignment": false }],
144-
"no-unreachable": "error",
145-
"no-unsafe-finally": "error",
146-
"no-unsafe-negation": "error",
147-
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true, "allowTaggedTemplates": true }],
148-
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
149-
"no-use-before-define": ["error", { "functions": false, "classes": false, "variables": false }],
150-
"no-useless-call": "error",
151-
"no-useless-computed-key": "error",
152-
"no-useless-constructor": "error",
153-
"no-useless-escape": "error",
154-
"no-useless-rename": "error",
155-
"no-useless-return": "error",
156-
"no-whitespace-before-property": "error",
157-
"no-with": "error",
158-
"object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
159-
"one-var": [0, { "initialized": "never" }],
160-
"operator-linebreak": ["error", "after", { "overrides": { "?": "before", ":": "before" } }],
161-
"padded-blocks": ["error", { "blocks": "never", "switches": "never", "classes": "never" }],
162-
"prefer-promise-reject-errors": "error",
163-
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
164-
"rest-spread-spacing": ["error", "never"],
165-
"semi": [1, "never"],
166-
"semi-spacing": ["error", { "before": false, "after": true }],
167-
"space-before-blocks": ["error", "always"],
168-
"space-before-function-paren": [1, "always"],
169-
"space-in-parens": ["error", "never"],
170-
"space-infix-ops": "error",
171-
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
172-
"spaced-comment": [1, "always", {
173-
"line": { "markers": ["*package", "!", "/", ",", "="] },
174-
"block": { "balanced": true, "markers": ["*package", "!", ",", ":", "::", "flow-include"], "exceptions": ["*"] }
175-
}],
176-
"symbol-description": "error",
177-
"template-curly-spacing": ["error", "never"],
178-
"template-tag-spacing": ["error", "never"],
179-
"unicode-bom": ["error", "never"],
180-
"use-isnan": "error",
181-
"valid-typeof": ["error", { "requireStringLiterals": true }],
182-
"wrap-iife": ["error", "any", { "functionPrototypeMethods": true }],
183-
"yield-star-spacing": ["error", "both"],
184-
"yoda": ["error", "never"],
185-
186-
"import/export": "error",
187-
"import/first": "error",
188-
"import/no-duplicates": "error",
189-
"import/no-webpack-loader-syntax": "error",
190-
191-
"node/no-deprecated-api": "error",
192-
"node/process-exit-as-throw": "error",
193-
194-
"promise/param-names": "error",
195-
196-
"standard/array-bracket-even-spacing": ["error", "either"],
197-
"standard/computed-property-even-spacing": ["error", "even"],
198-
"standard/no-callback-literal": 0,
199-
"standard/object-curly-even-spacing": ["error", "either"],
200-
"react/jsx-uses-vars": "error",
201-
"react/jsx-uses-react": "error",
202-
"babel/new-cap": 1,
203-
"babel/no-invalid-this": 1,
204-
"babel/object-curly-spacing": 1,
205-
"babel/quotes": 1,
206-
"babel/semi": 1
207-
}
37+
"react/destructuring-assignment": "warn"
38+
},
39+
"extends": "airbnb",
20840
}

bin/www

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
#!/usr/bin/env node
2-
const path = require('path')
3-
process.env['NODE_CONFIG_DIR'] = path.resolve(__dirname, '../server/config')
4-
const config = require('config')
5-
console.log(`读取配置文件${config.env}.js`)
6-
const app = require('../server/index').default
7-
const http = require('http')
8-
const server = http.createServer(app)
9-
server.listen(config.port, config.ip)
2+
const path = require('path');
3+
const http = require('http');
4+
5+
process.env.NODE_CONFIG_DIR = path.resolve(__dirname, '../server/config');
6+
const config = require('config');
7+
8+
console.log(`读取配置文件${config.env}.js`);
9+
const app = require('../server/index').default;
10+
11+
const server = http.createServer(app);
12+
server.listen(config.port, config.ip);
1013
server.on('error', (error) => {
11-
throw error
12-
})
14+
throw error;
15+
});
1316
server.on('listening', () => {
14-
console.log(`启动成功,监听端口:${server.address().port}`)
15-
})
17+
console.log(`启动成功,监听端口:${server.address().port}`);
18+
});

0 commit comments

Comments
 (0)