From bbed70b969f5e1a9d7afc125196270acbfa2addb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=98=8E=E5=81=A5?= Date: Wed, 7 Jun 2023 00:01:05 +0800 Subject: [PATCH] refactor: use existing rules (#198) --- packages/eslint-config-basic/index.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/eslint-config-basic/index.js b/packages/eslint-config-basic/index.js index 121773f..69d5d1d 100644 --- a/packages/eslint-config-basic/index.js +++ b/packages/eslint-config-basic/index.js @@ -263,23 +263,10 @@ module.exports = { 'error', { name: 'global', message: 'Use `globalThis` instead.' }, { name: 'self', message: 'Use `globalThis` instead.' }, - { name: 'isNaN', message: 'Use `Number.isNaN` instead.' }, - { name: 'isFinite', message: 'Use `Number.isFinite` instead.' }, - { name: 'parseFloat', message: 'Use `Number.parseFloat` instead.' }, - { name: 'parseInt', message: 'Use `Number.parseInt` instead.' }, ], 'no-restricted-properties': [ 'error', - { object: 'globalThis', property: 'isNaN', message: 'Use `Number.isNaN` instead.' }, - { object: 'globalThis', property: 'isFinite', message: 'Use `Number.isFinite` instead.' }, - { object: 'globalThis', property: 'parseFloat', message: 'Use `Number.parseFloat` instead.' }, - { object: 'globalThis', property: 'parseInt', message: 'Use `Number.parseInt` instead.' }, - { object: 'window', property: 'isNaN', message: 'Use `Number.isNaN` instead.' }, - { object: 'window', property: 'isFinite', message: 'Use `Number.isFinite` instead.' }, - { object: 'window', property: 'parseFloat', message: 'Use `Number.parseFloat` instead.' }, - { object: 'window', property: 'parseInt', message: 'Use `Number.parseInt` instead.' }, - { object: 'Math', property: 'pow', message: 'Use the exponentiation operator (**) instead.' }, - { property: '__proto__', message: 'Use `Object.getPrototypeOf` instead.' }, + { property: '__proto__', message: 'Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.' }, { property: '__defineGetter__', message: 'Use `Object.defineProperty` instead.' }, { property: '__defineSetter__', message: 'Use `Object.defineProperty` instead.' }, { property: '__lookupGetter__', message: 'Use `Object.getOwnPropertyDescriptor` instead.' }, @@ -379,6 +366,8 @@ module.exports = { 'unicorn/throw-new-error': 'error', // Prefer using the node: protocol 'unicorn/prefer-node-protocol': 'error', + // Prefer using number properties like `Number.isNaN` rather than `isNaN` + 'unicorn/prefer-number-properties': 'error', 'no-use-before-define': ['error', { functions: false, classes: false, variables: true }], 'eslint-comments/disable-enable-pair': 'off',