Skip to content

Commit

Permalink
enable eslint-plugin-node
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Sep 10, 2019
1 parent 79a46e9 commit 5a66505
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 61 deletions.
32 changes: 30 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -497,7 +512,7 @@ const qunit = {
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2019,
ecmaVersion: 2020,
},
env: {
browser: true,
Expand All @@ -506,6 +521,7 @@ module.exports = {
},
plugins: [
'import',
'node',
'optimize-regex',
'qunit',
'sonarjs',
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions packages/core-js-compat/src/build-modules-by-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ' '));
7 changes: 5 additions & 2 deletions packages/core-js/internals/array-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
9 changes: 4 additions & 5 deletions packages/core-js/internals/global.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
var O = 'object';
var check = function (it) {
return it && it.Math == Math && 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')();
48 changes: 24 additions & 24 deletions tests/promises-aplus-native.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Promises/A+ Tests, Against Your Browser!</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.css" />
<meta charset="utf-8" />
<title>Promises/A+ Tests, Against Your Browser!</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js"></script>
<script>
mocha.setup({ ui: "bdd", timeout: 1e3, slow: Infinity });
<div id="mocha"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js"></script>
<script>
mocha.setup({ ui: "bdd", timeout: 1e3, slow: Infinity });

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)
};
</script>
<script src="bundles/promises-aplus.js"></script>
<script>
mocha.run();
</script>
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)
};
</script>
<script src="bundles/promises-aplus.js"></script>
<script>
mocha.run();
</script>
</body>
</html>
50 changes: 25 additions & 25 deletions tests/promises-aplus.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Promises/A+ Tests, Against Your Browser!</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.css" />
<meta charset="utf-8" />
<title>Promises/A+ Tests, Against Your Browser!</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.css" />
</head>
<body>
<div id="mocha"></div>
<script src="../packages/core-js-bundle/index.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js"></script>
<script>
mocha.setup({ ui: "bdd", timeout: 1e3, slow: Infinity });
<div id="mocha"></div>
<script src="../packages/core-js-bundle/index.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js"></script>
<script>
mocha.setup({ ui: "bdd", timeout: 1e3, slow: Infinity });

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)
};
</script>
<script src="bundles/promises-aplus.js"></script>
<script>
mocha.run();
</script>
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)
};
</script>
<script src="bundles/promises-aplus.js"></script>
<script>
mocha.run();
</script>
</body>
</html>

0 comments on commit 5a66505

Please sign in to comment.