From aefa76e48a4e0b35607ffa2312fec2ee4747df90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=98=8E=E5=81=A5?= Date: Wed, 31 May 2023 15:51:21 +0800 Subject: [PATCH] feat(basic): ban some deprecated global functions (#190) --- packages/eslint-config-basic/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/eslint-config-basic/index.js b/packages/eslint-config-basic/index.js index 3e0c916..373a605 100644 --- a/packages/eslint-config-basic/index.js +++ b/packages/eslint-config-basic/index.js @@ -259,7 +259,23 @@ module.exports = { asyncArrow: 'always', }, ], - 'no-restricted-globals': ['error', { name: 'global', message: 'Use `globalThis` instead.' }], + 'no-restricted-globals': [ + 'error', + { name: 'global', message: 'Use `globalThis` instead.' }, + { name: 'self', message: 'Use `globalThis` instead.' }, + { name: 'window', 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' }, + ], // es6 'no-var': 'error',