Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(eslint): ♻️ add eslint-plugin-n to eslint configuration #528

Merged
merged 8 commits into from Jun 15, 2023
7 changes: 7 additions & 0 deletions .eslintrc.cjs
Expand Up @@ -17,6 +17,7 @@ module.exports = {
extends: [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:n/recommended",
"plugin:perfectionist/recommended-natural",
"plugin:regexp/recommended",
"prettier",
Expand Down Expand Up @@ -126,6 +127,12 @@ module.exports = {
// These off/less-strict-by-default rules work well for this repo and we like them on.
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }],
"import/extensions": ["error", "ignorePackages"],
"n/no-missing-import": [
"error",
{
allowModules: ["template-typescript-node-package"],
},
],
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
"no-only-tests/no-only-tests": "error",

// These on-by-default rules don't work well for this repo and we like them off.
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -67,6 +67,7 @@
"eslint-plugin-jsdoc": "^46.0.0",
"eslint-plugin-jsonc": "^2.8.0",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-perfectionist": "^1.1.2",
"eslint-plugin-regexp": "^1.15.0",
Expand Down
43 changes: 37 additions & 6 deletions pnpm-lock.yaml

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

11 changes: 8 additions & 3 deletions src/hydrate/steps/writing/creation/rootFiles.ts
Expand Up @@ -46,6 +46,7 @@ module.exports = {
extends: [
"eslint:recommended",
"plugin:eslint-comments/recommended",
"plugin:n/recommended",
"plugin:perfectionist/recommended-natural",
"plugin:regexp/recommended",
"prettier",
Expand Down Expand Up @@ -148,9 +149,13 @@ module.exports = {
rules: {
// These off/less-strict-by-default rules work well for this repo and we like them on.
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }],
"import/extensions": ["error", "ignorePackages"],${
values.unitTests ? `\n"no-only-tests/no-only-tests": "error",` : ""
}
"import/extensions": ["error", "ignorePackages"],
"n/no-missing-import": [
"error",
{
allowModules: ["template-typescript-node-package"],
},
],${values.unitTests ? `\n"no-only-tests/no-only-tests": "error",` : ""}

// These on-by-default rules don't work well for this repo and we like them off.
"no-case-declarations": "off",
Expand Down
3 changes: 2 additions & 1 deletion src/shared/getOctokit.ts
Expand Up @@ -25,7 +25,8 @@ export async function getOctokit(
console.error();
console.error(chalk.red((error as Error).message));
console.error();
process.exit(0);
// eslint-disable-next-line n/no-process-exit
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
process.exit(1);
}

const auth = (await $`gh auth token`).stdout.trim();
Expand Down
5 changes: 3 additions & 2 deletions src/shared/prompts.ts
@@ -1,8 +1,9 @@
import * as prompts from "@clack/prompts";

export function handleCancel(): never {
export function handleCancel() {
prompts.cancel("Operation cancelled. Exiting - maybe another time? 👋");
process.exit(0);
// eslint-disable-next-line n/no-process-exit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems process.exit(1) is important to terminate the CLI from this point onwards. So added eslint disable next line.

process.exit(1);
}

export function handlePromptCancel(
Expand Down