Skip to content
This repository was archived by the owner on Sep 6, 2018. It is now read-only.

Commit 7554922

Browse files
committed
update eslint
1 parent 7770ae9 commit 7554922

15 files changed

+127
-246
lines changed

.eslintignore

-2
This file was deleted.

.eslintrc.js

+28-144
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
'use strict';
22

33
module.exports = {
4-
extends: 'eslint:recommended',
4+
extends: 'airbnb',
5+
parser: 'babel-eslint',
56
parserOptions: {
6-
ecmaVersion: 2017,
7+
ecmaVersion: 2018,
8+
sourceType: 'script',
79
ecmaFeatures: {
810
experimentalObjectRestSpread: true,
911
},
@@ -16,18 +18,18 @@ module.exports = {
1618
{
1719
files: ['*.jsx'],
1820
parserOptions: {
21+
sourceType: 'module',
1922
ecmaFeatures: { jsx: true },
2023
},
2124
},
2225
{
2326
files: ['*.mjs'],
2427
parserOptions: { sourceType: 'module' },
2528
env: {
26-
node: false,
29+
node: true,
2730
},
28-
globals: {
29-
Buffer: false,
30-
process: false,
31+
rules: {
32+
'no-restricted-globals': ['error', 'require'],
3133
},
3234
},
3335
{
@@ -36,144 +38,26 @@ module.exports = {
3638
},
3739
],
3840
rules: {
39-
'no-await-in-loop': 'warn',
40-
'no-compare-neg-zero': 'error',
41-
'no-extra-parens': ['warn', 'all', { nestedBinaryExpressions: false }],
42-
'no-template-curly-in-string': 'error',
43-
'no-unsafe-negation': 'error',
44-
'valid-jsdoc': [
45-
'error',
46-
{
47-
requireReturn: false,
48-
requireReturnDescription: false,
49-
prefer: { return: 'returns', arg: 'param' },
50-
preferType: {
51-
String: 'string',
52-
Number: 'number',
53-
Boolean: 'boolean',
54-
Symbol: 'symbol',
55-
object: 'Object',
56-
function: 'Function',
57-
array: 'Array',
58-
date: 'Date',
59-
error: 'Error',
60-
null: 'void',
61-
},
62-
},
63-
],
64-
'accessor-pairs': 'warn',
65-
'array-callback-return': 'error',
66-
complexity: 'warn',
67-
'consistent-return': 'off',
68-
curly: ['error', 'multi-or-nest', 'consistent'],
69-
'dot-location': ['error', 'property'],
70-
'dot-notation': 'error',
71-
eqeqeq: 'error',
72-
'no-empty-function': 'error',
73-
'no-floating-decimal': 'error',
74-
'no-implied-eval': 'error',
75-
'no-invalid-this': 'error',
76-
'no-lone-blocks': 'error',
77-
'no-multi-spaces': 'error',
78-
'no-new-func': 'error',
79-
'no-new-wrappers': 'error',
80-
'no-new': 'error',
81-
'no-octal-escape': 'error',
82-
'no-return-assign': 'error',
83-
'no-return-await': 'error',
84-
'no-self-compare': 'error',
85-
'no-sequences': 'error',
86-
'no-throw-literal': 'error',
87-
'no-unmodified-loop-condition': 'error',
88-
'no-unused-expressions': 'error',
89-
'no-useless-call': 'error',
90-
'no-useless-concat': 'error',
91-
'no-useless-escape': 'error',
92-
'no-useless-return': 'error',
93-
'no-void': 'error',
94-
'no-warning-comments': 'warn',
95-
'prefer-promise-reject-errors': 'error',
96-
'require-await': 'warn',
97-
'wrap-iife': 'error',
98-
yoda: 'error',
99-
'no-label-var': 'error',
100-
'no-shadow': 'error',
101-
'no-undef-init': 'error',
102-
'callback-return': 'error',
103-
'handle-callback-err': 'error',
104-
'no-mixed-requires': 'error',
105-
'no-new-require': 'error',
106-
'no-path-concat': 'error',
107-
'array-bracket-spacing': 'error',
108-
'block-spacing': 'error',
109-
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
110-
'capitalized-comments': ['off', 'always', { ignoreConsecutiveComments: true }],
111-
'comma-dangle': ['error', 'always-multiline'],
112-
'comma-spacing': 'error',
113-
'comma-style': 'error',
114-
'computed-property-spacing': 'error',
115-
'consistent-this': ['error', '$this'],
116-
'eol-last': 'error',
117-
'func-names': 'error',
118-
'func-name-matching': 'error',
119-
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
120-
indent: ['error', 2, { SwitchCase: 1 }],
121-
'key-spacing': 'error',
122-
'keyword-spacing': 'error',
123-
'max-depth': 'error',
124-
'max-len': ['error', 120, 2],
125-
'max-nested-callbacks': ['error', { max: 4 }],
126-
'max-statements-per-line': ['error', { max: 2 }],
127-
'new-cap': 'off',
128-
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 3 }],
129-
'no-array-constructor': 'error',
130-
'no-inline-comments': 'off',
131-
'no-lonely-if': 'error',
132-
'no-mixed-operators': 'error',
133-
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1, maxBOF: 0 }],
134-
'no-new-object': 'error',
135-
'no-spaced-func': 'error',
136-
'no-trailing-spaces': 'error',
137-
'no-unneeded-ternary': 'error',
138-
'no-whitespace-before-property': 'error',
139-
'nonblock-statement-body-position': ['error', 'below'],
140-
'object-curly-spacing': ['error', 'always'],
141-
'operator-assignment': 'error',
142-
'operator-linebreak': ['error', 'after'],
143-
'padded-blocks': ['error', 'never'],
144-
'quote-props': ['error', 'as-needed'],
145-
quotes: [
146-
'error',
147-
'single',
148-
{ avoidEscape: true, allowTemplateLiterals: true },
149-
],
150-
'semi-spacing': 'error',
151-
semi: 'error',
152-
'space-before-blocks': 'error',
153-
'space-before-function-paren': [
154-
'error',
155-
{ anonymous: 'never', named: 'never', asyncArrow: 'always' },
156-
],
157-
'space-in-parens': 'error',
158-
'space-infix-ops': 'error',
159-
'space-unary-ops': 'error',
160-
'spaced-comment': 'error',
161-
'template-tag-spacing': 'error',
162-
'unicode-bom': 'error',
163-
'arrow-body-style': 'error',
41+
'strict': ['error', 'global'],
42+
'curly': ['error', 'multi-or-nest', 'consistent'],
43+
'no-iterator': 'off',
44+
'global-require': 'off',
45+
'quote-props': ['error', 'consistent-as-needed'],
46+
'no-param-reassign': 'off',
16447
'arrow-parens': ['error', 'always'],
165-
'arrow-spacing': 'error',
166-
'no-duplicate-imports': 'error',
167-
'no-useless-computed-key': 'error',
168-
'no-useless-constructor': 'error',
169-
'prefer-arrow-callback': 'error',
170-
'prefer-numeric-literals': 'error',
171-
'prefer-rest-params': 'error',
172-
'prefer-spread': 'error',
173-
'prefer-template': 'error',
174-
'rest-spread-spacing': 'error',
175-
'template-curly-spacing': 'error',
176-
'yield-star-spacing': 'error',
177-
strict: ['error', 'global'],
48+
'no-multi-assign': 'off',
49+
'no-underscore-dangle': 'off',
50+
'no-restricted-syntax': 'off',
51+
'object-curly-newline': 'off',
52+
'import/no-dynamic-require': 'off',
53+
'import/no-extraneous-dependencies': ['error', {
54+
devDependencies: true,
55+
}],
56+
'import/extensions': 'off',
57+
},
58+
globals: {
59+
WebAssembly: false,
60+
BigInt: false,
61+
URL: false,
17862
},
17963
};

package.json

+12-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"unpkg": "browser.js",
77
"jsdelivr": "browser.js",
88
"scripts": {
9-
"lint": "eslint . --cache --ext=mjs,js",
9+
"setup": "install-peerdeps --dev eslint-config-airbnb",
10+
"lint": "eslint --ext=mjs,js src test sync.js webpack.config.js",
1011
"test": "node ./node_modules/.bin/jest",
1112
"coverage": "cat ./coverage/lcov.info | coveralls",
1213
"docs": "node docs.js",
@@ -27,14 +28,21 @@
2728
"dependencies": {},
2829
"devDependencies": {
2930
"@snek/syncify": "0.0.6",
31+
"babel-eslint": "^8.2.2",
3032
"coveralls": "^3.0.0",
3133
"docma": "^1.5.1",
32-
"eslint": "^4.8.0",
34+
"eslint": "^4.19.1",
35+
"eslint-config-airbnb": "^16.1.0",
36+
"eslint-plugin-import": "^2.10.0",
37+
"eslint-plugin-jsx-a11y": "^6.0.3",
38+
"eslint-plugin-react": "^7.7.0",
39+
"form-data": "^2.3.2",
40+
"install-peerdeps": "^1.6.0",
3341
"jest": "^21.2.1",
3442
"jsdoc-dynamic": "^1.0.4",
3543
"json-filter-loader": "^1.0.0",
36-
"node-fetch": "^2.0.0",
37-
"uglifyjs-webpack-plugin": "^1.0.0-beta.2",
44+
"node-fetch": "^2.1.2",
45+
"uglifyjs-webpack-plugin": "^1.2.4",
3846
"webpack": "^3.8.1"
3947
},
4048
"description": "Just do http requests without all that weird nastiness from other libs",

scripts/travis-test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set -e
22

3+
npm run setup
34
npm run lint
45
npm run test
56

src/browser/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function request(snek) {
1111
for (const [k, v] of r.headers.entries())
1212
headers[k.toLowerCase()] = v;
1313
return {
14-
raw, headers,
14+
raw,
15+
headers,
1516
statusCode: r.status,
1617
statusText: r.statusText,
1718
};

src/index.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,11 @@ class Snekfetch extends transport.Parent {
177177
statusText,
178178
};
179179

180-
if (res.ok) {
180+
if (res.ok)
181181
return res;
182-
} else {
183-
const err = new Error(`${statusCode} ${statusText}`.trim());
184-
Object.assign(err, res);
185-
return Promise.reject(err);
186-
}
182+
const err = new Error(`${statusCode} ${statusText}`.trim());
183+
Object.assign(err, res);
184+
return Promise.reject(err);
187185
})
188186
.then(resolver, rejector);
189187
}
@@ -199,8 +197,8 @@ class Snekfetch extends transport.Parent {
199197
*/
200198
end(cb) {
201199
return this.then(
202-
(res) => cb ? cb(null, res) : res,
203-
(err) => cb ? cb(err, err.status ? err : null) : Promise.reject(err)
200+
(res) => (cb ? cb(null, res) : res),
201+
(err) => (cb ? cb(err, err.status ? err : null) : Promise.reject(err)),
204202
);
205203
}
206204

src/index.mjs

+35-35
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@ import Snekfetch from './index.js';
22

33
export default Snekfetch;
44

5-
export const version = Snekfetch.version;
6-
export const METHODS = Snekfetch.METHODS;
5+
export const { version } = Snekfetch;
6+
export const { METHODS } = Snekfetch;
77

8-
export const acl = Snekfetch.acl;
9-
export const bind = Snekfetch.bind;
10-
export const checkout = Snekfetch.checkout;
11-
export const connect = Snekfetch.connect;
12-
export const copy = Snekfetch.copy;
13-
const _delete = Snekfetch.delete;
8+
export const { acl } = Snekfetch;
9+
export const { bind } = Snekfetch;
10+
export const { checkout } = Snekfetch;
11+
export const { connect } = Snekfetch;
12+
export const { copy } = Snekfetch;
13+
const { delete: _delete } = Snekfetch;
1414
export { _delete as delete };
15-
export const get = Snekfetch.get;
16-
export const head = Snekfetch.head;
17-
export const link = Snekfetch.link;
18-
export const lock = Snekfetch.lock;
19-
export const merge = Snekfetch.merge;
20-
export const mkactivity = Snekfetch.mkactivity;
21-
export const mkcalendar = Snekfetch.mkcalendar;
22-
export const mkcol = Snekfetch.mkcol;
23-
export const move = Snekfetch.move;
24-
export const notify = Snekfetch.notify;
25-
export const options = Snekfetch.options;
26-
export const patch = Snekfetch.patch;
27-
export const post = Snekfetch.post;
28-
export const propfind = Snekfetch.propfind;
29-
export const proppatch = Snekfetch.proppatch;
30-
export const purge = Snekfetch.purge;
31-
export const put = Snekfetch.put;
32-
export const rebind = Snekfetch.rebind;
33-
export const report = Snekfetch.report;
34-
export const search = Snekfetch.search;
35-
export const subscribe = Snekfetch.subscribe;
36-
export const trace = Snekfetch.trace;
37-
export const unbind = Snekfetch.unbind;
38-
export const unlink = Snekfetch.unlink;
39-
export const unlock = Snekfetch.unlock;
40-
export const unsubscribe = Snekfetch.unsubscribe;
41-
export const brew = Snekfetch.brew;
15+
export const { get } = Snekfetch;
16+
export const { head } = Snekfetch;
17+
export const { link } = Snekfetch;
18+
export const { lock } = Snekfetch;
19+
export const { merge } = Snekfetch;
20+
export const { mkactivity } = Snekfetch;
21+
export const { mkcalendar } = Snekfetch;
22+
export const { mkcol } = Snekfetch;
23+
export const { move } = Snekfetch;
24+
export const { notify } = Snekfetch;
25+
export const { options } = Snekfetch;
26+
export const { patch } = Snekfetch;
27+
export const { post } = Snekfetch;
28+
export const { propfind } = Snekfetch;
29+
export const { proppatch } = Snekfetch;
30+
export const { purge } = Snekfetch;
31+
export const { put } = Snekfetch;
32+
export const { rebind } = Snekfetch;
33+
export const { report } = Snekfetch;
34+
export const { search } = Snekfetch;
35+
export const { source } = Snekfetch;
36+
export const { subscribe } = Snekfetch;
37+
export const { trace } = Snekfetch;
38+
export const { unbind } = Snekfetch;
39+
export const { unlink } = Snekfetch;
40+
export const { unlock } = Snekfetch;
41+
export const { unsubscribe } = Snekfetch;

0 commit comments

Comments
 (0)