Skip to content

Commit

Permalink
fix: fixed the errors of eslint (#1675)
Browse files Browse the repository at this point in the history
* fix: fixed the errors of eslint

* style: remove unused eslint comment
  • Loading branch information
yunnysunny authored Jan 22, 2022
1 parent 1fd4f90 commit 84206c7
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 10 deletions.
14 changes: 12 additions & 2 deletions .dist.eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["eslint:recommended"],
"extends": ["eslint:recommended", "plugin:compat/recommended"],
"env": {
"node": false,
"browser": true,
Expand All @@ -8,6 +8,14 @@
},
"plugins": ["compat"],
"rules": {
"node/no-unsupported-features/es-builtins": ["error", {
"version": ">=8.0.0",
"ignores": [
"Atomics",
"BigInt",
"SharedArrayBuffer"
]
}],
"compat/compat": "error",
"no-console": "off",
"no-empty": "off",
Expand Down Expand Up @@ -44,7 +52,9 @@
"Reflect",
"WeakMap",
"WeakRef",
"WeakSet"
"WeakSet",
"Atomics",
"SharedArrayBuffer"
]
}
}
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"extends": [
"eslint:recommended",
"plugin:node/recommended"
],
"env": {
"node": true,
"browser": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2021
},
"overrides": [
{
"files": "test/**/*.js",
"env": {
"mocha": true
},
"rules": {
"no-prototype-builtins": "off",
"node/no-deprecated-api": "warn",
"node/no-extraneous-require": "warn",
"no-unused-vars": "warn"
}
}
],
"rules": {
"node/no-unsupported-features/node-builtins": "off",
"node/no-unsupported-features/es-syntax": "off",
"node/no-exports-assign": "off"
},
"globals": {
"ActiveXObject": "readonly"
}


}
8 changes: 7 additions & 1 deletion .lib.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"no-console": "off",
"no-unused-vars": "off",
"no-empty": "off",
"node/no-unsupported-features/node-builtins": "off",
"no-func-assign": "off",
"no-global-assign": ["error", {"exceptions": ["exports"]}],
"no-fallthrough": "off",
Expand All @@ -22,6 +21,13 @@
"globals": {
"ActiveXObject": "readable"
}
},
{
"files": [ "lib/node/http2wrapper.js" ],
"rules": {
"node/no-unsupported-features/es-builtins": "off",
"node/no-unsupported-features/node-builtins": "off"
}
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"build:dist": "npm run browserify && npm run minify",
"build:lib": "babel --config-file ./.lib.babelrc src --out-dir lib",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"lint": "xo && remark . -qfo && eslint -c .lib.eslintrc lib && eslint -c .dist.eslintrc dist",
"lint": "eslint -c .eslintrc src test && remark . -qfo && eslint -c .lib.eslintrc lib/**/*.js && eslint -c .dist.eslintrc dist/**/*.js",
"minify": "cross-env NODE_ENV=production browserify src/node/index.js -o dist/superagent.min.js -s superagent -g [ babelify --configFile ./.dist.babelrc ] -p tinyify",
"nyc": "cross-env NODE_ENV=test nyc ava",
"test": "npm run build && npm run lint && make test",
Expand All @@ -165,6 +165,7 @@
"xo": {
"prettier": true,
"space": true,
"nodeVersion": false,
"extends": [
"xo-lass"
],
Expand Down
8 changes: 4 additions & 4 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ request.getXHR = () => {

try {
return new ActiveXObject('Microsoft.XMLHTTP');
} catch {}
} catch {/**/}

try {
return new ActiveXObject('Msxml2.XMLHTTP.6.0');
} catch {}
} catch {/**/}

try {
return new ActiveXObject('Msxml2.XMLHTTP.3.0');
} catch {}
} catch {/**/}

try {
return new ActiveXObject('Msxml2.XMLHTTP');
} catch {}
} catch {/**/}

throw new Error('Browser-only version of superagent could not find XHR');
};
Expand Down
1 change: 0 additions & 1 deletion test/client/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ describe('request', function () {

try {
var file = new File([''], 'image.jpg', { type: 'image/jpeg' });
// eslint-disable-next-line unicorn/prefer-optional-catch-binding
} catch (err) {
// Skip if file constructor not supported.
return next();
Expand Down
2 changes: 1 addition & 1 deletion test/node/toError.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ before(function listen(done) {

describe('res.toError()', () => {
it('should return an Error', (done) => {
request.get(base).end((error, res) => {
request.get(base).end((err, res) => {
var error = res.toError();
assert.equal(error.status, 400);
assert.equal(error.method, 'GET');
Expand Down

0 comments on commit 84206c7

Please sign in to comment.