diff --git a/.eslintrc.js b/.eslintrc.js index 4bd19eefb185..a33a48a20aa4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -288,6 +288,12 @@ const base = { // forbid useless path segments 'import/no-useless-path-segments': 'error', + // node: + // enforce the style of file extensions in `import` declarations + 'node/file-extension-in-import': ['error', 'never'], + // disallow the assignment to `exports` + 'node/no-exports-assign': 'error', + // es6: // require parentheses around arrow function arguments 'arrow-parens': ['error', 'as-needed'], @@ -412,6 +418,15 @@ const es3 = { 'prefer-destructuring': 'off', }; +const node = { + // disallow deprecated APIs + 'node/no-deprecated-api': 'error', + // disallow unsupported ECMAScript built-ins on the specified version + 'node/no-unsupported-features/es-builtins': ['error', { version: '>=8.0.0' }], + // disallow unsupported ECMAScript syntax on the specified version + 'node/no-unsupported-features/es-syntax': ['error', { version: '>=8.0.0' }], +}; + const tests = { // require strict mode directives strict: 'off', @@ -497,7 +512,7 @@ const qunit = { module.exports = { root: true, parserOptions: { - ecmaVersion: 2019, + ecmaVersion: 2020, }, env: { browser: true, @@ -506,6 +521,7 @@ module.exports = { }, plugins: [ 'import', + 'node', 'optimize-regex', 'qunit', 'sonarjs', @@ -561,9 +577,21 @@ module.exports = { files: [ 'packages/core-js-builder/**', 'packages/core-js-compat/**', + 'tests/commonjs.js', + '.eslintrc.js', + '.webpack.config.js', + 'babel.config.js', + 'Gruntfile.js', + ], + env: { + es6: true, + }, + rules: node, + }, + { + files: [ 'tests/tests/**', 'tests/compat/**', - 'tests/commonjs.js', ], env: { es6: true, diff --git a/package.json b/package.json index 36d5e5813706..d8c78004b047 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "eslint": "^6.3.0", "eslint-import-resolver-webpack": "^0.11.1", "eslint-plugin-import": "^2.18.2", + "eslint-plugin-node": "^10.0.0", "eslint-plugin-optimize-regex": "^1.1.6", "eslint-plugin-qunit": "^4.0.0", "eslint-plugin-sonarjs": "^0.4.0", diff --git a/packages/core-js-compat/src/build-modules-by-versions.js b/packages/core-js-compat/src/build-modules-by-versions.js index f1813c24b67c..2ec940e3c591 100644 --- a/packages/core-js-compat/src/build-modules-by-versions.js +++ b/packages/core-js-compat/src/build-modules-by-versions.js @@ -10,7 +10,6 @@ for (const version of Object.values(modulesByVersions)) { for (const module of version) modules.delete(module); } -writeFileSync(resolve(__dirname, '../modules-by-versions.json'), JSON.stringify({ +writeFileSync(resolve(__dirname, '../modules-by-versions.json'), JSON.stringify(Object.assign({ '3.0': [...modules], - ...modulesByVersions, -}, null, ' ')); +}, modulesByVersions), null, ' ')); diff --git a/packages/core-js/internals/array-buffer.js b/packages/core-js/internals/array-buffer.js index d2d33fdcdd16..560d5304380d 100644 --- a/packages/core-js/internals/array-buffer.js +++ b/packages/core-js/internals/array-buffer.js @@ -291,5 +291,8 @@ if (!NATIVE_ARRAY_BUFFER) { setToStringTag($ArrayBuffer, ARRAY_BUFFER); setToStringTag($DataView, DATA_VIEW); -exports[ARRAY_BUFFER] = $ArrayBuffer; -exports[DATA_VIEW] = $DataView; + +module.exports = { + ArrayBuffer: $ArrayBuffer, + DataView: $DataView +}; diff --git a/packages/core-js/internals/global.js b/packages/core-js/internals/global.js index bb744f126f06..cf00638f1a81 100644 --- a/packages/core-js/internals/global.js +++ b/packages/core-js/internals/global.js @@ -1,4 +1,3 @@ -var O = 'object'; var check = function (it) { return it && it.Math == Math && it; }; @@ -6,9 +5,9 @@ var check = function (it) { // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 module.exports = // eslint-disable-next-line no-undef - check(typeof globalThis == O && globalThis) || - check(typeof window == O && window) || - check(typeof self == O && self) || - check(typeof global == O && global) || + check(typeof globalThis == 'object' && globalThis) || + check(typeof window == 'object' && window) || + check(typeof self == 'object' && self) || + check(typeof global == 'object' && global) || // eslint-disable-next-line no-new-func Function('return this')(); diff --git a/tests/promises-aplus-native.html b/tests/promises-aplus-native.html index 0d0a5312d45b..73910238514b 100644 --- a/tests/promises-aplus-native.html +++ b/tests/promises-aplus-native.html @@ -1,32 +1,32 @@ - - Promises/A+ Tests, Against Your Browser! - + + Promises/A+ Tests, Against Your Browser! + -
- - + - - + window.adapter = { + deferred: function () { + var deferred = {}; + deferred.promise = new Promise(function (resolve, reject) { + deferred.resolve = resolve; + deferred.reject = reject; + }); + return deferred; + }, + resolved: Promise.resolve.bind(Promise), + rejected: Promise.reject.bind(Promise) + }; + + + diff --git a/tests/promises-aplus.html b/tests/promises-aplus.html index 7b5a18bac7d6..31a612c1fb6f 100644 --- a/tests/promises-aplus.html +++ b/tests/promises-aplus.html @@ -1,33 +1,33 @@ - - Promises/A+ Tests, Against Your Browser! - + + Promises/A+ Tests, Against Your Browser! + -
- - - + + - - + window.adapter = { + deferred: function () { + var deferred = {}; + deferred.promise = new Promise(function (resolve, reject) { + deferred.resolve = resolve; + deferred.reject = reject; + }); + return deferred; + }, + resolved: Promise.resolve.bind(Promise), + rejected: Promise.reject.bind(Promise) + }; + + +