diff --git a/config/eslint/node.cjs b/config/eslint/node.cjs index 75f82e0f190..6210609092b 100644 --- a/config/eslint/node.cjs +++ b/config/eslint/node.cjs @@ -1,6 +1,8 @@ function defaults(config) { const result = { - files: !config?.useModules ? ['./babel.config.js', './.eslintrc.cjs', './index.js', './addon-main.cjs', './addon-main.js'] : [], + files: !config?.useModules + ? ['./babel.config.js', './.eslintrc.cjs', './index.js', './addon-main.cjs', './addon-main.js'] + : [], parserOptions: { sourceType: config?.useModules ? 'module' : 'script', ecmaVersion: 2022, @@ -11,6 +13,8 @@ function defaults(config) { es6: true, }, globals: config?.globals || {}, + plugins: ['n'], + extends: 'plugin:n/recommended', }; if (config?.files) { @@ -21,5 +25,5 @@ function defaults(config) { } module.exports = { - defaults + defaults, }; diff --git a/config/eslint/parser.cjs b/config/eslint/parser.cjs index 5c92be34f05..38e898287df 100644 --- a/config/eslint/parser.cjs +++ b/config/eslint/parser.cjs @@ -6,7 +6,7 @@ function defaults() { ecmaVersion: 2022, sourceType: 'module', babelOptions: { - // eslint-disable-next-line node/no-unpublished-require + // eslint-disable-next-line n/no-unpublished-require plugins: [[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }]], }, requireConfigFile: false, @@ -15,5 +15,5 @@ function defaults() { } module.exports = { - defaults + defaults, }; diff --git a/config/package.json b/config/package.json index 1eb9e50fb25..f7b741ed15f 100644 --- a/config/package.json +++ b/config/package.json @@ -11,6 +11,7 @@ "eslint": "^8.52.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.29.0", + "eslint-plugin-n": "^16.2.0", "eslint-plugin-prettier": "^5.0.1", "eslint-plugin-simple-import-sort": "^10.0.0", "prettier": "^3.0.3", @@ -23,4 +24,4 @@ "extends": "../../package.json" }, "packageManager": "pnpm@8.9.2" -} \ No newline at end of file +} diff --git a/packages/private-build-infra/src/utilities/detect-module.js b/packages/private-build-infra/src/utilities/detect-module.js index e4969635388..3f758015fc3 100644 --- a/packages/private-build-infra/src/utilities/detect-module.js +++ b/packages/private-build-infra/src/utilities/detect-module.js @@ -75,7 +75,7 @@ module.exports = function detectModule(require, moduleName, baseDir, pkg) { bustCache(require); // ember-data brings all packages so if present we are present // - // eslint-disable-next-line node/no-missing-require + // eslint-disable-next-line n/no-missing-require require.resolve('ember-data', { paths: [baseDir, path.join(baseDir, '../'), process.cwd()] }); log('\t✅ FOUND ember-data'); return true; diff --git a/packages/unpublished-test-infra/ember-cli-build.js b/packages/unpublished-test-infra/ember-cli-build.js index 93f726983af..b3f346a9756 100644 --- a/packages/unpublished-test-infra/ember-cli-build.js +++ b/packages/unpublished-test-infra/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint node/no-unpublished-require: 'off' */ +/* eslint n/no-unpublished-require: 'off' */ 'use strict'; diff --git a/packages/unpublished-test-infra/index.js b/packages/unpublished-test-infra/index.js index 9a4b16da32f..31460ea85c7 100644 --- a/packages/unpublished-test-infra/index.js +++ b/packages/unpublished-test-infra/index.js @@ -1,5 +1,5 @@ 'use strict'; -// eslint-disable-next-line node/no-unpublished-require +// eslint-disable-next-line n/no-unpublished-require const merge = require('broccoli-merge-trees'); const version = require('@ember-data/private-build-infra/src/create-version-module'); const addonBuildConfigForDataPackage = require('@ember-data/private-build-infra/src/addon-build-config-for-data-package'); diff --git a/packages/unpublished-test-infra/src/testem/testem.js b/packages/unpublished-test-infra/src/testem/testem.js index a5702ea87b5..efe20b75cf3 100644 --- a/packages/unpublished-test-infra/src/testem/testem.js +++ b/packages/unpublished-test-infra/src/testem/testem.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ /* eslint-disable no-console */ const fs = require('node:fs'); const path = require('node:path'); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e0a8e25aa5f..3e6020556a3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -123,6 +123,9 @@ importers: eslint-plugin-import: specifier: ^2.29.0 version: 2.29.0(@typescript-eslint/parser@6.8.0)(eslint@8.52.0) + eslint-plugin-n: + specifier: ^16.2.0 + version: 16.2.0(eslint@8.52.0) eslint-plugin-prettier: specifier: ^5.0.1 version: 5.0.1(eslint-config-prettier@9.0.0)(eslint@8.52.0)(prettier@3.0.3) @@ -11665,6 +11668,17 @@ packages: - supports-color dev: false + /eslint-plugin-es-x@7.2.0(eslint@8.52.0): + resolution: {integrity: sha512-9dvv5CcvNjSJPqnS5uZkqb3xmbeqRLnvXKK7iI5+oK/yTusyc46zbBZKENGsOfojm/mKfszyZb+wNqNPAPeGXA==} + engines: {node: ^14.18.0 || >=16.0.0} + peerDependencies: + eslint: '>=8' + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.52.0) + '@eslint-community/regexpp': 4.9.1 + eslint: 8.52.0 + dev: false + /eslint-plugin-import@2.29.0(@typescript-eslint/parser@6.8.0)(eslint@8.52.0): resolution: {integrity: sha512-QPOO5NO6Odv5lpoTkddtutccQjysJuFxoPS7fAHO+9m9udNHvTCPSAMW9zGAYj8lAIdr40I8yPCdUYrncXtrwg==} engines: {node: '>=4'} @@ -11700,6 +11714,24 @@ packages: - supports-color dev: false + /eslint-plugin-n@16.2.0(eslint@8.52.0): + resolution: {integrity: sha512-AQER2jEyQOt1LG6JkGJCCIFotzmlcCZFur2wdKrp1JX2cNotC7Ae0BcD/4lLv3lUAArM9uNS8z/fsvXTd0L71g==} + engines: {node: '>=16.0.0'} + peerDependencies: + eslint: '>=7.0.0' + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.52.0) + builtins: 5.0.1 + eslint: 8.52.0 + eslint-plugin-es-x: 7.2.0(eslint@8.52.0) + get-tsconfig: 4.7.2 + ignore: 5.2.4 + is-core-module: 2.13.1 + minimatch: 3.1.2 + resolve: 1.22.8 + semver: 7.5.4 + dev: false + /eslint-plugin-prettier@5.0.1(eslint-config-prettier@9.0.0)(eslint@8.52.0)(prettier@3.0.3): resolution: {integrity: sha512-m3u5RnR56asrwV/lDC4GHorlW75DsFfmUcjfCYylTUs85dBRnB7VM6xG8eCMJdeDRnppzmxZVf1GEPJvl1JmNg==} engines: {node: ^14.18.0 || >=16.0.0} @@ -12695,6 +12727,12 @@ packages: call-bind: 1.0.5 get-intrinsic: 1.2.2 + /get-tsconfig@4.7.2: + resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} + dependencies: + resolve-pkg-maps: 1.0.0 + dev: false + /get-uri@6.0.2: resolution: {integrity: sha512-5KLucCJobh8vBY1K07EFV4+cPZH3mrV9YeAruUseCQKHB58SGjjT2l9/eA9LD082IiuMjSlFJEcdJ27TXvbZNw==} engines: {node: '>= 14'} @@ -16213,6 +16251,10 @@ packages: http-errors: 1.6.3 path-is-absolute: 1.0.1 + /resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + dev: false + /resolve-url@0.2.1: resolution: {integrity: sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==} deprecated: https://github.com/lydell/resolve-url#deprecated diff --git a/tests/builders/ember-cli-build.js b/tests/builders/ember-cli-build.js index d4c71986688..36cec92dcc8 100644 --- a/tests/builders/ember-cli-build.js +++ b/tests/builders/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); diff --git a/tests/docs/index.js b/tests/docs/index.js index 3ae88a6abbf..09c0b3cc639 100644 --- a/tests/docs/index.js +++ b/tests/docs/index.js @@ -25,7 +25,7 @@ function linkItem(item) { QUnit.module('Docs coverage', function (hooks) { // data.json is generated and not always present. So this disable needs to be preserved. - const docs = require('../../packages/-ember-data/dist/docs/data.json'); // eslint-disable-line node/no-missing-require + const docs = require('../../packages/-ember-data/dist/docs/data.json'); // eslint-disable-line n/no-missing-require const expected = require('./fixtures/expected'); function classIsPublic(className) { diff --git a/tests/ember-data__adapter/ember-cli-build.js b/tests/ember-data__adapter/ember-cli-build.js index f0116ce6cd9..665f118b239 100644 --- a/tests/ember-data__adapter/ember-cli-build.js +++ b/tests/ember-data__adapter/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint node/no-unpublished-require: 'off' */ +/* eslint n/no-unpublished-require: 'off' */ 'use strict'; diff --git a/tests/ember-data__graph/ember-cli-build.js b/tests/ember-data__graph/ember-cli-build.js index 835b7b92729..d26fe6ad220 100644 --- a/tests/ember-data__graph/ember-cli-build.js +++ b/tests/ember-data__graph/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); diff --git a/tests/ember-data__json-api/ember-cli-build.js b/tests/ember-data__json-api/ember-cli-build.js index b57e15a9247..c05a1eb8e45 100644 --- a/tests/ember-data__json-api/ember-cli-build.js +++ b/tests/ember-data__json-api/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); diff --git a/tests/ember-data__model/ember-cli-build.js b/tests/ember-data__model/ember-cli-build.js index d51a1731ef4..b087fcc8e2d 100644 --- a/tests/ember-data__model/ember-cli-build.js +++ b/tests/ember-data__model/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint node/no-unpublished-require: 'off' */ +/* eslint n/no-unpublished-require: 'off' */ 'use strict'; diff --git a/tests/ember-data__request/ember-cli-build.js b/tests/ember-data__request/ember-cli-build.js index d4c71986688..36cec92dcc8 100644 --- a/tests/ember-data__request/ember-cli-build.js +++ b/tests/ember-data__request/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); diff --git a/tests/ember-data__serializer/ember-cli-build.js b/tests/ember-data__serializer/ember-cli-build.js index 134b4335df7..76f3d28dcf9 100644 --- a/tests/ember-data__serializer/ember-cli-build.js +++ b/tests/ember-data__serializer/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint node/no-unpublished-require: 'off' */ +/* eslint n/no-unpublished-require: 'off' */ 'use strict'; diff --git a/tests/ember-data__serializer/testem.js b/tests/ember-data__serializer/testem.js index e10b064501a..fb97c3f065e 100644 --- a/tests/ember-data__serializer/testem.js +++ b/tests/ember-data__serializer/testem.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line node/no-unpublished-require +// eslint-disable-next-line n/no-unpublished-require const customDotReporter = require('@ember-data/unpublished-test-infra/src/testem/custom-dot-reporter'); // eslint-disable-next-line no-console diff --git a/tests/embroider-basic-compat/ember-cli-build.js b/tests/embroider-basic-compat/ember-cli-build.js index 260b79902b1..72dc141789f 100644 --- a/tests/embroider-basic-compat/ember-cli-build.js +++ b/tests/embroider-basic-compat/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint node/no-unpublished-require: 'off' */ +/* eslint n/no-unpublished-require: 'off' */ 'use strict'; diff --git a/tests/embroider-basic-compat/testem.js b/tests/embroider-basic-compat/testem.js index e10b064501a..fb97c3f065e 100644 --- a/tests/embroider-basic-compat/testem.js +++ b/tests/embroider-basic-compat/testem.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line node/no-unpublished-require +// eslint-disable-next-line n/no-unpublished-require const customDotReporter = require('@ember-data/unpublished-test-infra/src/testem/custom-dot-reporter'); // eslint-disable-next-line no-console diff --git a/tests/fastboot/ember-cli-build.js b/tests/fastboot/ember-cli-build.js index 4a994397055..dd83666aa50 100644 --- a/tests/fastboot/ember-cli-build.js +++ b/tests/fastboot/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint node/no-unpublished-require: 'off' */ +/* eslint n/no-unpublished-require: 'off' */ 'use strict'; diff --git a/tests/fastboot/testem.js b/tests/fastboot/testem.js index e10b064501a..fb97c3f065e 100644 --- a/tests/fastboot/testem.js +++ b/tests/fastboot/testem.js @@ -1,4 +1,4 @@ -// eslint-disable-next-line node/no-unpublished-require +// eslint-disable-next-line n/no-unpublished-require const customDotReporter = require('@ember-data/unpublished-test-infra/src/testem/custom-dot-reporter'); // eslint-disable-next-line no-console diff --git a/tests/full-data-asset-size-app/ember-cli-build.js b/tests/full-data-asset-size-app/ember-cli-build.js index 06d52ab1735..48fa8bb7d62 100644 --- a/tests/full-data-asset-size-app/ember-cli-build.js +++ b/tests/full-data-asset-size-app/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); diff --git a/tests/main/config/ember-try.js b/tests/main/config/ember-try.js index 07324e541fc..1d86de32bac 100644 --- a/tests/main/config/ember-try.js +++ b/tests/main/config/ember-try.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const getChannelURL = require('ember-source-channel-url'); diff --git a/tests/main/ember-cli-build.js b/tests/main/ember-cli-build.js index d55b963d018..f0732b64a2c 100644 --- a/tests/main/ember-cli-build.js +++ b/tests/main/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); diff --git a/tests/main/testem.js b/tests/main/testem.js index cdb3576b4bd..101394b3ac5 100644 --- a/tests/main/testem.js +++ b/tests/main/testem.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ const TestemConfig = require('@ember-data/unpublished-test-infra/src/testem/testem'); module.exports = TestemConfig; diff --git a/tests/performance/ember-cli-build.js b/tests/performance/ember-cli-build.js index 20d6b1e7c92..7b316bfcffc 100644 --- a/tests/performance/ember-cli-build.js +++ b/tests/performance/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint node/no-unpublished-require: 'off' */ +/* eslint n/no-unpublished-require: 'off' */ 'use strict'; diff --git a/tests/recommended-json-api/ember-cli-build.js b/tests/recommended-json-api/ember-cli-build.js index 88b537b4826..fd2ea6503c6 100644 --- a/tests/recommended-json-api/ember-cli-build.js +++ b/tests/recommended-json-api/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); diff --git a/tests/recommended-json-api/server/index.js b/tests/recommended-json-api/server/index.js index daaf688c1f3..1d9786c7502 100644 --- a/tests/recommended-json-api/server/index.js +++ b/tests/recommended-json-api/server/index.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; // To use it create some files under `mocks/` diff --git a/tests/recommended-json-api/server/mocks/book.js b/tests/recommended-json-api/server/mocks/book.js index a8f0c22d468..6535bfcb0e8 100644 --- a/tests/recommended-json-api/server/mocks/book.js +++ b/tests/recommended-json-api/server/mocks/book.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const RAW_BOOKS = require('./MOCK_DATA.json'); diff --git a/tests/recommended-json-api/testem.js b/tests/recommended-json-api/testem.js index a85540f243d..914019b375e 100644 --- a/tests/recommended-json-api/testem.js +++ b/tests/recommended-json-api/testem.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ const customDotReporter = require('@ember-data/unpublished-test-infra/src/testem/custom-dot-reporter'); // eslint-disable-next-line no-console diff --git a/tests/warp-drive__schema-record/ember-cli-build.js b/tests/warp-drive__schema-record/ember-cli-build.js index 2fa1e887d48..3bd56e6a047 100644 --- a/tests/warp-drive__schema-record/ember-cli-build.js +++ b/tests/warp-drive__schema-record/ember-cli-build.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ 'use strict'; const EmberApp = require('ember-cli/lib/broccoli/ember-app'); diff --git a/tests/warp-drive__schema-record/testem.js b/tests/warp-drive__schema-record/testem.js index a85540f243d..914019b375e 100644 --- a/tests/warp-drive__schema-record/testem.js +++ b/tests/warp-drive__schema-record/testem.js @@ -1,4 +1,4 @@ -/* eslint-disable node/no-unpublished-require */ +/* eslint-disable n/no-unpublished-require */ const customDotReporter = require('@ember-data/unpublished-test-infra/src/testem/custom-dot-reporter'); // eslint-disable-next-line no-console