Skip to content

Commit

Permalink
Add eslint-plugin-n to eslint config for node files
Browse files Browse the repository at this point in the history
  • Loading branch information
gitKrystan committed Oct 25, 2023
1 parent fb5b968 commit 6c85b6b
Show file tree
Hide file tree
Showing 32 changed files with 80 additions and 33 deletions.
8 changes: 6 additions & 2 deletions config/eslint/node.cjs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -11,6 +13,8 @@ function defaults(config) {
es6: true,
},
globals: config?.globals || {},
plugins: ['n'],
extends: 'plugin:n/recommended',
};

if (config?.files) {
Expand All @@ -21,5 +25,5 @@ function defaults(config) {
}

module.exports = {
defaults
defaults,
};
4 changes: 2 additions & 2 deletions config/eslint/parser.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,5 +15,5 @@ function defaults() {
}

module.exports = {
defaults
defaults,
};
3 changes: 2 additions & 1 deletion config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -23,4 +24,4 @@
"extends": "../../package.json"
},
"packageManager": "[email protected]"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/unpublished-test-infra/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint node/no-unpublished-require: 'off' */
/* eslint n/no-unpublished-require: 'off' */

'use strict';

Expand Down
2 changes: 1 addition & 1 deletion packages/unpublished-test-infra/index.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion packages/unpublished-test-infra/src/testem/testem.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
42 changes: 42 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/builders/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ember-data__adapter/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint node/no-unpublished-require: 'off' */
/* eslint n/no-unpublished-require: 'off' */

'use strict';

Expand Down
2 changes: 1 addition & 1 deletion tests/ember-data__graph/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/ember-data__json-api/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/ember-data__model/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint node/no-unpublished-require: 'off' */
/* eslint n/no-unpublished-require: 'off' */

'use strict';

Expand Down
2 changes: 1 addition & 1 deletion tests/ember-data__request/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/ember-data__serializer/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint node/no-unpublished-require: 'off' */
/* eslint n/no-unpublished-require: 'off' */

'use strict';

Expand Down
2 changes: 1 addition & 1 deletion tests/ember-data__serializer/testem.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/embroider-basic-compat/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint node/no-unpublished-require: 'off' */
/* eslint n/no-unpublished-require: 'off' */

'use strict';

Expand Down
2 changes: 1 addition & 1 deletion tests/embroider-basic-compat/testem.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/fastboot/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint node/no-unpublished-require: 'off' */
/* eslint n/no-unpublished-require: 'off' */

'use strict';

Expand Down
2 changes: 1 addition & 1 deletion tests/fastboot/testem.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/full-data-asset-size-app/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/main/config/ember-try.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/main/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/main/testem.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion tests/performance/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint node/no-unpublished-require: 'off' */
/* eslint n/no-unpublished-require: 'off' */

'use strict';

Expand Down
2 changes: 1 addition & 1 deletion tests/recommended-json-api/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/recommended-json-api/server/index.js
Original file line number Diff line number Diff line change
@@ -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/`
Expand Down
2 changes: 1 addition & 1 deletion tests/recommended-json-api/server/mocks/book.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
2 changes: 1 addition & 1 deletion tests/recommended-json-api/testem.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/warp-drive__schema-record/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/warp-drive__schema-record/testem.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 6c85b6b

Please sign in to comment.