Skip to content

Commit

Permalink
Merge pull request #9057 from emberjs/eslint-node-config
Browse files Browse the repository at this point in the history
  • Loading branch information
gitKrystan authored Oct 25, 2023
2 parents 3a43769 + 9845438 commit a8f8630
Show file tree
Hide file tree
Showing 79 changed files with 201 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"files.associations": {
"turbo.json": "jsonc"
},
"eslint.workingDirectories": ["packages/*", "tests/*"]
"eslint.workingDirectories": [{ "mode": "auto" }, "packages/*", "tests/*"]
}
34 changes: 34 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "pnpm: lint",
"type": "shell",
"command": "pnpm lint",

"problemMatcher": {
"owner": "pnpm-lint",
"fileLocation": ["absolute"],
"background": {
"activeOnStart": true,
"beginsPattern": "^Scope: .* workspace projects$",
"endsPattern": "^Summary: .* fails, .* passes$"
},
"pattern": [
{
"regexp": "^.+lint: (\\/.+)$",
"file": 1
},
{
"regexp": "^.+lint:\\s+(\\d+):(\\d+)\\s+(\\w+)\\s+(.+)$",
"line": 1,
"column": 2,
"severity": 3,
"message": 4,
"loop": true
}
]
}
}
]
}
35 changes: 33 additions & 2 deletions config/eslint/node.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function defaults(config) {
const result = {
files: !config?.useModules ? ['./babel.config.js', './.eslintrc.cjs', './index.js', './addon-main.cjs', './addon-main.js'] : [],
files: !config?.useModules ? ['./index.js', './addon-main.cjs', './addon-main.js'] : [],
parserOptions: {
sourceType: config?.useModules ? 'module' : 'script',
ecmaVersion: 2022,
Expand All @@ -11,6 +11,36 @@ function defaults(config) {
es6: true,
},
globals: config?.globals || {},
plugins: ['n'],
extends: 'plugin:n/recommended',
};

if (config?.files) {
result.files.push(...config.files);
}

return result;
}

function config(config) {
const result = {
files: ['./babel.config.js', './.eslintrc.cjs', './rollup.config.mjs'],
parserOptions: {
sourceType: config?.useModules ? 'module' : 'script',
ecmaVersion: 2022,
},
env: {
browser: false,
node: true,
es6: true,
},
globals: config?.globals || {},
plugins: ['n'],
extends: 'plugin:n/recommended',
rules: {
// It's ok to use unpublished files here since we don't ship these
'n/no-unpublished-require': 'off',
},
};

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

module.exports = {
defaults
defaults,
config,
};
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]"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"prepare": "pnpm build",
"build": "turbo _build --log-order=stream --filter=./packages/*",
"build:docs": "mkdir -p packages/-ember-data/dist && cd ./docs-generator && node ./compile-docs.js",
"lint": "pnpm run -r --workspace-concurrency=-1 --if-present lint",
"lint": "FORCE_COLOR=2 pnpm run -r --workspace-concurrency=-1 --if-present --reporter=append-only --no-bail lint",
"preinstall": "npx only-allow pnpm",
"check:types": "pnpm run -r --workspace-concurrency=-1 --if-present check:types",
"test": "pnpm turbo test --concurrency=1",
Expand Down Expand Up @@ -139,4 +139,4 @@
"[email protected]": "patches/[email protected]"
}
}
}
}
2 changes: 1 addition & 1 deletion packages/-ember-data/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};
2 changes: 1 addition & 1 deletion packages/-ember-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "tests"
},
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"move-dts": "bun ../../scripts/copy-declarations.mjs addon",
"build:types": "tsc --build",
"_build": "bun run build:types && bun run move-dts",
Expand Down
2 changes: 1 addition & 1 deletion packages/active-record/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};
2 changes: 1 addition & 1 deletion packages/active-record/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}
},
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"build:types": "tsc --build",
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
"_build": "bun run build:client && bun run build:types",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};
2 changes: 1 addition & 1 deletion packages/adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "",
"directories": {},
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"build:types": "tsc --build",
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
"_build": "bun run build:client && bun run build:types",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-types/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};
2 changes: 1 addition & 1 deletion packages/core-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "MIT",
"author": "Chris Thoburn <[email protected]>",
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"build:types": "tsc --build",
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
"_build": "bun run build:client && bun run build:types",
Expand Down
2 changes: 1 addition & 1 deletion packages/debug/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults()],
overrides: [node.config(), node.defaults()],
};
2 changes: 1 addition & 1 deletion packages/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "",
"directories": {},
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"_syncPnpm": "bun run sync-dependencies-meta-injected"
},
"peerDependencies": {
Expand Down
7 changes: 6 additions & 1 deletion packages/diagnostic/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ module.exports = {
ignorePatterns: ignore.ignoreRules(),

overrides: [
node.config(),
node.defaults(),
node.defaults({ useModules: true, globals: { Bun: true }, files: ['./server/**'] }),
node.defaults({
files: ['./server/**'],
useModules: true,
globals: { Bun: true },
}),
typescript.defaults({
rules: {
'no-console': 'off',
Expand Down
3 changes: 2 additions & 1 deletion packages/diagnostic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
}
},
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"build:tests": "rm -rf dist-test && cp -R test dist-test && mkdir -p dist-test/@warp-drive && cp -R dist dist-test/@warp-drive/diagnostic",
"build:types": "tsc --build",
"build:runtime": "rollup --config",
Expand Down Expand Up @@ -99,6 +99,7 @@
"@babel/preset-typescript": "^7.23.2",
"@babel/runtime": "^7.23.2",
"@embroider/addon-dev": "^4.1.1",
"@embroider/addon-shim": "^1.8.6",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.2.3",
"@warp-drive/internal-config": "workspace:5.5.0-alpha.11",
Expand Down
4 changes: 2 additions & 2 deletions packages/diagnostic/server/browsers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import os from 'os';
import path from 'path';
import tmp from 'tmp';

import { debug } from '../utils/debug';
import { isWin, platformName } from '../utils/platform';
import { debug } from '../utils/debug.js';
import { isWin, platformName } from '../utils/platform.js';

export function getHomeDir() {
return process.env.HOME || process.env.USERPROFILE;
Expand Down
5 changes: 5 additions & 0 deletions packages/diagnostic/server/bun/socket-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export function buildHandler(config, state) {
await config.cleanup();
debug(`Configured cleanup hook completed`);
}
// 1. We expect all cleanup to have happened after
// config.cleanup(), so exiting here should be safe.
// 2. We also want to forcibly exit with a success code in this
// case.
// eslint-disable-next-line n/no-process-exit
process.exit(exitCode);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/graph/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};
2 changes: 1 addition & 1 deletion packages/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "MIT",
"author": "Chris Thoburn <[email protected]>",
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"build:types": "tsc --build",
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
"_build": "bun run build:client && bun run build:types",
Expand Down
2 changes: 1 addition & 1 deletion packages/holodeck/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};
2 changes: 1 addition & 1 deletion packages/json-api/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};
2 changes: 1 addition & 1 deletion packages/json-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"license": "MIT",
"author": "",
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"build:types": "tsc --build",
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
"_build": "bun run build:client && bun run build:types",
Expand Down
2 changes: 1 addition & 1 deletion packages/legacy-compat/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const config = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};

module.exports = config;
2 changes: 1 addition & 1 deletion packages/legacy-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}
},
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"build:types": "tsc --build",
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
"_build": "bun run build:client && bun run build:types",
Expand Down
2 changes: 1 addition & 1 deletion packages/model/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ module.exports = {

ignorePatterns: ignore.ignoreRules(),

overrides: [node.defaults(), typescript.defaults()],
overrides: [node.config(), node.defaults(), typescript.defaults()],
};
2 changes: 1 addition & 1 deletion packages/model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "",
"directories": {},
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs",
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"move-dts": "bun ../../scripts/copy-declarations.mjs src",
"build:types": "tsc --build && bun run move-dts",
"build:client": "rollup --config && babel ./addon --out-dir addon --plugins=../private-build-infra/src/transforms/babel-plugin-transform-ext.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,6 @@ function handleCompletedRelationshipRequest(
// has never been accessed
if (proxy && !isHasMany) {
// @ts-expect-error unsure why this is not resolving the boolean but async belongsTo is weird
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (proxy.content && proxy.content.isDestroying) {
(proxy as PromiseBelongsTo).set('content', null);
}
Expand Down
1 change: 0 additions & 1 deletion packages/model/src/-private/references/belongs-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ export default class BelongsToReference {
const record = this.store.push(jsonApiDoc);

if (DEBUG) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
assertPolymorphicType(
this.belongsToRelationship.identifier,
this.belongsToRelationship.definition,
Expand Down
1 change: 0 additions & 1 deletion packages/model/src/-private/references/has-many.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ export default class HasManyReference {
const relationshipMeta = this.hasManyRelationship.definition;
const identifier = this.hasManyRelationship.identifier;

// eslint-disable-next-line @typescript-eslint/no-unsafe-call
assertPolymorphicType(identifier, relationshipMeta, recordIdentifierFor(record), store);
}
return recordIdentifierFor(record);
Expand Down
Loading

0 comments on commit a8f8630

Please sign in to comment.