Skip to content

Commit

Permalink
Initial lint config for tests/blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
gitKrystan committed Oct 25, 2023
1 parent 2ca4a57 commit 64fdf9e
Show file tree
Hide file tree
Showing 34 changed files with 133 additions and 36 deletions.
19 changes: 14 additions & 5 deletions config/eslint/node.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
function defaults(config) {
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',
sourceType: config.useModules ? 'module' : 'script',
ecmaVersion: 2022,
},
env: {
browser: false,
node: true,
es6: true,
...config.env,
},
globals: config.globals || {},
plugins: ['n', 'import'],
extends: 'plugin:n/recommended',
rules: {
'import/order': ['error', { 'newlines-between': 'always' }],
...config.rules,
},
globals: config?.globals || {},
};

if (config?.files) {
Expand All @@ -21,5 +30,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",
"pnpm-sync-dependencies-meta-injected": "0.0.10",
Expand All @@ -24,4 +25,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.

43 changes: 43 additions & 0 deletions tests/blueprints/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const imports = require('@warp-drive/internal-config/eslint/imports.cjs');
const parser = require('@warp-drive/internal-config/eslint/parser.cjs');
const isolation = require('@warp-drive/internal-config/eslint/isolation.cjs');
const ignore = require('@warp-drive/internal-config/eslint/ignore.cjs');
const node = require('@warp-drive/internal-config/eslint/node.cjs');
const base = require('@warp-drive/internal-config/eslint/base.cjs');

module.exports = {
...parser.defaults(),

plugins: [...base.plugins(), ...imports.plugins()],
extends: [...base.extend()],
rules: Object.assign(
base.rules(),
imports.rules(),
// { allowedImports: ['@ember/debug', 'ember-inflector', '@ember/string'] }
isolation.rules(),
{}
),

ignorePatterns: ignore.ignoreRules(),

overrides: [
node.defaults({
useModules: true,
files: ['tests/**/*.{js,ts}'],
env: {
mocha: true,
},
rules: {
'n/no-unpublished-require': 'off',
},
}),
node.defaults({
useModules: true,
files: ['fixtures/**/*.{js,ts}'],
rules: {
'import/order': 'off',
'simple-import-sort/imports': 'off',
},
}),
],
};
2 changes: 2 additions & 0 deletions tests/blueprints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"license": "MIT",
"author": "",
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"test:blueprints": "mocha tests",
"_syncPnpm": "bun run sync-dependencies-meta-injected"
},
Expand Down Expand Up @@ -89,6 +90,7 @@
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@warp-drive/core-types": "workspace:5.5.0-alpha.11",
"@warp-drive/internal-config": "workspace:5.5.0-alpha.11",
"ember-cli": "~5.3.0",
"ember-cli-blueprint-test-helpers": "^0.19.2",
"ember-inflector": "^4.0.2",
Expand Down
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 64fdf9e

Please sign in to comment.