Skip to content

Commit

Permalink
enable some rules from eslint-plugin-n(ode)
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Sep 7, 2023
1 parent 06ce4ba commit 44f3ce9
Show file tree
Hide file tree
Showing 473 changed files with 578 additions and 563 deletions.
1 change: 1 addition & 0 deletions packages/core-js/postinstall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
/* eslint-disable node/no-sync -- avoiding overcomplicating */
var fs = require('fs');
var os = require('os');
var path = require('path');
Expand Down
18 changes: 16 additions & 2 deletions tests/eslint/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,16 @@ const base = {
'import/no-useless-path-segments': ERROR,

// node:
// disallow deprecated APIs
'node/no-deprecated-api': ERROR,
// enforce the style of file extensions in `import` declarations
'node/file-extension-in-import': ERROR,
// require require() calls to be placed at top-level module scope
'node/global-require': ERROR,
// disallow deprecated APIs
'node/no-deprecated-api': ERROR,
// disallow the assignment to `exports`
'node/no-exports-assign': ERROR,
// disallow third-party modules which are hiding core modules
'node/no-hide-core-modules': ERROR,
// disallow require calls to be mixed with regular variable declarations
'node/no-mixed-requires': [ERROR, { grouping: true, allowCall: false }],
// disallow new operators with calls to require
Expand All @@ -468,6 +472,8 @@ const base = {
'node/no-path-concat': ERROR,
// disallow the use of `process.exit()`
'node/no-process-exit': ERROR,
// disallow synchronous methods
'node/no-sync': ERROR,
// prefer global
'node/prefer-global/buffer': [ERROR, ALWAYS],
'node/prefer-global/console': [ERROR, ALWAYS],
Expand All @@ -476,6 +482,9 @@ const base = {
'node/prefer-global/text-encoder': [ERROR, ALWAYS],
'node/prefer-global/url-search-params': [ERROR, ALWAYS],
'node/prefer-global/url': [ERROR, ALWAYS],
// prefer promises
'node/prefer-promises/dns': ERROR,
'node/prefer-promises/fs': ERROR,

// array-func:
// avoid reversing the array and running a method on it if there is an equivalent of the method operating on the array from the other end
Expand Down Expand Up @@ -1117,8 +1126,13 @@ const nodePackages = {
'array-func/prefer-flat': OFF,
// enforces the use of `catch()` on un-returned promises
'promise/catch-or-return': ERROR,
// disallow third-party modules which are hiding core modules
'node/no-hide-core-modules': OFF,
// disallow unsupported ECMAScript built-ins on the specified version
'node/no-unsupported-features/node-builtins': [ERROR, { version: PACKAGES_NODE_VERSIONS }],
// prefer promises
'node/prefer-promises/dns': OFF,
'node/prefer-promises/fs': OFF,
...disable(forbidES5BuiltIns),
...disable(forbidES2015BuiltIns),
...disable(forbidES2016BuiltIns),
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/qunit-helpers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DESCRIPTORS } from './constants';
import { DESCRIPTORS } from './constants.js';
import assign from 'core-js-pure/es/object/assign';
import defineProperties from 'core-js-pure/es/object/define-properties';
import isIterable from 'core-js-pure/es/is-iterable';
import ASYNC_ITERATOR from 'core-js-pure/es/symbol/async-iterator';
import { is, arrayFromArrayLike } from './helpers';
import { is, arrayFromArrayLike } from './helpers.js';

// for Babel template transform
if (!Object.freeze) Object.freeze = Object;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array-buffer.constructor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, GLOBAL, NATIVE } from '../helpers/constants';
import { DESCRIPTORS, GLOBAL, NATIVE } from '../helpers/constants.js';

QUnit.test('ArrayBuffer', assert => {
const Symbol = GLOBAL.Symbol || {};
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array-buffer.is-view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TYPED_ARRAYS } from '../helpers/constants';
import { TYPED_ARRAYS } from '../helpers/constants.js';

QUnit.test('ArrayBuffer.isView', assert => {
const { isView } = ArrayBuffer;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array-buffer.slice.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arrayToBuffer, bufferToArray } from '../helpers/helpers';
import { arrayToBuffer, bufferToArray } from '../helpers/helpers.js';

QUnit.test('ArrayBuffer#slice', assert => {
const { slice } = ArrayBuffer.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.at.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#at', assert => {
const { at } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.copy-within.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#copyWithin', assert => {
const { copyWithin } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.every.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#every', assert => {
const { every } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.fill.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, NATIVE, STRICT } from '../helpers/constants';
import { DESCRIPTORS, NATIVE, STRICT } from '../helpers/constants.js';

QUnit.test('Array#fill', assert => {
const { fill } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#filter', assert => {
const { filter } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.find-index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#findIndex', assert => {
const { findIndex } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.find-last-index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#findLastIndex', assert => {
const { findLastIndex } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.find-last.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#findLast', assert => {
const { findLast } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.find.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#find', assert => {
const { find } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.flat-map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable unicorn/prefer-array-flat -- required for testing */
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#flatMap', assert => {
const { flatMap } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.flat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, STRICT } from '../helpers/constants';
import { DESCRIPTORS, STRICT } from '../helpers/constants.js';

QUnit.test('Array#flat', assert => {
const { flat } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.for-each.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#forEach', assert => {
const { forEach } = Array.prototype;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit-global/es.array.from.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable prefer-rest-params -- required for testing */
import { DESCRIPTORS, GLOBAL } from '../helpers/constants';
import { createIterable } from '../helpers/helpers';
import { DESCRIPTORS, GLOBAL } from '../helpers/constants.js';
import { createIterable } from '../helpers/helpers.js';

QUnit.test('Array.from', assert => {
const Symbol = GLOBAL.Symbol || {};
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.includes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#includes', assert => {
const { includes } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.index-of.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#indexOf', assert => {
const { indexOf } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.iterator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GLOBAL } from '../helpers/constants';
import { GLOBAL } from '../helpers/constants.js';

const Symbol = GLOBAL.Symbol || {};

Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.join.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#join', assert => {
const { join } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.last-index-of.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#lastIndexOf', assert => {
const { lastIndexOf } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#map', assert => {
const { map } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.of.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS } from '../helpers/constants';
import { DESCRIPTORS } from '../helpers/constants.js';

QUnit.test('Array.of', assert => {
const { defineProperty } = Object;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.push.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants.js';

const { defineProperty } = Object;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.reduce-right.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#reduceRight', assert => {
const { reduceRight } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.reduce.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#reduce', assert => {
const { reduce } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.reverse.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#reverse', assert => {
const { reverse } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.slice.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GLOBAL, STRICT } from '../helpers/constants';
import { GLOBAL, STRICT } from '../helpers/constants.js';

QUnit.test('Array#slice', assert => {
const { slice } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.some.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#some', assert => {
const { some } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.sort.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#sort', assert => {
const { sort } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.splice.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants.js';

const { defineProperty } = Object;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.to-reversed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#toReversed', assert => {
const { toReversed } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.to-sorted.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#toSorted', assert => {
const { toSorted } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.to-spliced.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#toSpliced', assert => {
const { toSpliced } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.unshift.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants';
import { REDEFINABLE_ARRAY_LENGTH_DESCRIPTOR, STRICT } from '../helpers/constants.js';

const { defineProperty } = Object;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.array.with.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Array#with', assert => {
const { with: withAt } = Array.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.data-view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS, NATIVE } from '../helpers/constants';
import { DESCRIPTORS, NATIVE } from '../helpers/constants.js';

QUnit.test('DataView', assert => {
assert.same(DataView, Object(DataView), 'is object'); // in Safari 5 typeof DataView is 'object'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.date.to-primitive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Date#@@toPrimitive', assert => {
const toPrimitive = Date.prototype[Symbol.toPrimitive];
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.error.cause.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GLOBAL, PROTO } from '../helpers/constants';
import { GLOBAL, PROTO } from '../helpers/constants.js';

const { create } = Object;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.error.to-string.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STRICT } from '../helpers/constants';
import { STRICT } from '../helpers/constants.js';

QUnit.test('Error#toString', assert => {
const { toString } = Error.prototype;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.function.name.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS } from '../helpers/constants';
import { DESCRIPTORS } from '../helpers/constants.js';

if (DESCRIPTORS) {
QUnit.test('Function#name', assert => {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.json.stringify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Some tests adopted from Test262 project and governed by the BSD license.
// Copyright (c) 2012 Ecma International. All rights reserved.
/* eslint-disable es/no-bigint,unicorn/no-hex-escape -- testing */
import { DESCRIPTORS, GLOBAL } from '../helpers/constants';
import { DESCRIPTORS, GLOBAL } from '../helpers/constants.js';

if (GLOBAL.JSON?.stringify) {
QUnit.test('JSON.stringify', assert => {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit-global/es.map.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable sonarjs/no-element-overwrite -- required for testing */

import { DESCRIPTORS, GLOBAL, NATIVE } from '../helpers/constants';
import { createIterable, is, nativeSubclass } from '../helpers/helpers';
import { DESCRIPTORS, GLOBAL, NATIVE } from '../helpers/constants.js';
import { createIterable, is, nativeSubclass } from '../helpers/helpers.js';

const Symbol = GLOBAL.Symbol || {};
const { getOwnPropertyDescriptor, keys, getOwnPropertyNames, getOwnPropertySymbols, freeze } = Object;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.acosh.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.acosh', assert => {
const { acosh } = Math;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.asinh.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.asinh', assert => {
const { asinh } = Math;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.atanh.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.atanh', assert => {
const { atanh } = Math;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.cbrt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.cbrt', assert => {
const { cbrt } = Math;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.clz32.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.clz32', assert => {
const { clz32 } = Math;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.cosh.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.cosh', assert => {
const { cosh } = Math;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.expm1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.expm1', assert => {
const { expm1 } = Math;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.fround.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

const { MAX_VALUE, MIN_VALUE } = Number;

Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.hypot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.hypot', assert => {
const { hypot, sqrt } = Math;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-global/es.math.imul.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createConversionChecker } from '../helpers/helpers';
import { createConversionChecker } from '../helpers/helpers.js';

QUnit.test('Math.imul', assert => {
const { imul } = Math;
Expand Down
Loading

0 comments on commit 44f3ce9

Please sign in to comment.