Skip to content

Commit

Permalink
update eslint-plugin-unicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 31, 2021
1 parent 53846c1 commit 1ff3a8c
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ const base = {
'unicorn/no-lonely-if': ERROR,
// forbid classes that only have static members
'unicorn/no-static-only-class': ERROR,
// disallow `then` property
'unicorn/no-thenable': ERROR,
// disallow unreadable array destructuring
'unicorn/no-unreadable-array-destructuring': ERROR,
// disallow unused object properties
Expand All @@ -402,6 +404,8 @@ const base = {
'unicorn/no-useless-fallback-in-spread': ERROR,
// disallow useless array length check
'unicorn/no-useless-length-check': ERROR,
// disallow returning / yielding `Promise.{ resolve, reject }` in async functions or promise callbacks
'unicorn/no-useless-promise-resolve-reject': ERROR,
// disallow useless spread
'unicorn/no-useless-spread': ERROR,
// enforce lowercase identifier and uppercase value for number literals
Expand All @@ -412,10 +416,14 @@ const base = {
'unicorn/prefer-code-point': ERROR,
// prefer default parameters over reassignment
'unicorn/prefer-default-parameters': ERROR,
// prefer reading a `JSON` file as a buffer
'unicorn/prefer-json-parse-buffer': ERROR,
// prefer `String#slice` over `String#{ substr, substring }`
'unicorn/prefer-string-slice': ERROR,
// prefer `switch` over multiple `else-if`
'unicorn/prefer-switch': [ERROR, { minimumCases: 3 }],
// enforce consistent relative `URL` style
'unicorn/relative-url-style': [ERROR, ALWAYS],
// enforce using the separator argument with `Array#join()`
'unicorn/require-array-join-separator': ERROR,
// enforce using the digits argument with `Number#toFixed()`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"eslint-plugin-qunit": "^7.2.0",
"eslint-plugin-regexp": "^1.5.1",
"eslint-plugin-sonarjs": "~0.11.0",
"eslint-plugin-unicorn": "^39.0.0",
"eslint-plugin-unicorn": "^40.0.0",
"jsonc-eslint-parser": "^2.0.4",
"karma": "^6.3.9",
"karma-phantomjs-launcher": "~1.0.4",
Expand Down
1 change: 1 addition & 0 deletions packages/core-js/internals/native-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var IS_PURE = require('../internals/is-pure');
var ITERATOR = wellKnownSymbol('iterator');

module.exports = !fails(function () {
// eslint-disable-next-line unicorn/relative-url-style -- required for testing
var url = new URL('b?a=1&b=2&c=3', 'http://a');
var searchParams = url.searchParams;
var result = '';
Expand Down
1 change: 1 addition & 0 deletions packages/core-js/modules/es.promise.finally.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var redefine = require('../internals/redefine');

// Safari bug https://bugs.webkit.org/show_bug.cgi?id=200829
var NON_GENERIC = !!NativePromise && fails(function () {
// eslint-disable-next-line unicorn/no-thenable -- required for testing
NativePromise.prototype['finally'].call({ then: function () { /* empty */ } }, function () { /* empty */ });
});

Expand Down
1 change: 1 addition & 0 deletions packages/core-js/modules/es.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ if (FORCED) {
Internal.prototype = redefineAll(PromisePrototype, {
// `Promise.prototype.then` method
// https://tc39.es/ecma262/#sec-promise.prototype.then
// eslint-disable-next-line unicorn/no-thenable -- safe
then: function then(onFulfilled, onRejected) {
var state = getInternalPromiseState(this);
var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function isBannerRequired() {
try {
var DELTA = Date.now() - fs.statSync(file).mtime;
if (DELTA >= 0 && DELTA < MINUTE * 3) {
banners = JSON.parse(fs.readFileSync(file, 'utf8'));
banners = JSON.parse(fs.readFileSync(file));
if (banners.indexOf(BANNER) !== -1) return false;
}
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions tests/compat/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var SYMBOLS_SUPPORT = function () {
};

var URL_AND_URL_SEARCH_PARAMS_SUPPORT = function () {
// eslint-disable-next-line unicorn/relative-url-style -- required for testing
var url = new URL('b?a=1&b=2&c=3', 'http://a');
var searchParams = url.searchParams;
var result = '';
Expand Down Expand Up @@ -805,6 +806,7 @@ GLOBAL.tests = {
return Promise.any;
},
'es.promise.finally': [PROMISES_SUPPORT, function () {
// eslint-disable-next-line unicorn/no-thenable -- required for testing
return Promise.prototype['finally'].call({ then: function () { return this; } }, function () { /* empty */ });
}],
'es.reflect.apply': function () {
Expand Down
1 change: 1 addition & 0 deletions tests/pure/es.promise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-thenable -- required for testing */
import { DESCRIPTORS, GLOBAL, PROTO, STRICT } from '../helpers/constants';
import { createIterable } from '../helpers/helpers';

Expand Down
2 changes: 1 addition & 1 deletion tests/pure/web.url.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable es/no-object-getownpropertydescriptor -- safe */
/* eslint-disable es/no-object-getownpropertydescriptor, unicorn/relative-url-style -- required for testing */
import { DESCRIPTORS, NODE } from '../helpers/constants';
import urlTestData from '../wpt-url-resources/urltestdata';
import settersTestData from '../wpt-url-resources/setters';
Expand Down
1 change: 1 addition & 0 deletions tests/tests/es.promise.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-thenable -- required for testing */
import { DESCRIPTORS, GLOBAL, NATIVE, PROTO, STRICT } from '../helpers/constants';
import { createIterable } from '../helpers/helpers';

Expand Down
1 change: 1 addition & 0 deletions tests/tests/web.url.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable unicorn/relative-url-style -- required for testing */
import { DESCRIPTORS, NODE } from '../helpers/constants';
import urlTestData from '../wpt-url-resources/urltestdata';
import settersTestData from '../wpt-url-resources/setters';
Expand Down

0 comments on commit 1ff3a8c

Please sign in to comment.