feat(basic): ban some deprecated global functions (#190)

This commit is contained in:
曾明健 2023-05-31 15:51:21 +08:00 committed by GitHub
parent e787e9a647
commit aefa76e48a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -259,7 +259,23 @@ module.exports = {
asyncArrow: 'always', 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 // es6
'no-var': 'error', 'no-var': 'error',