Skip to content

Commit 052c41a

Browse files
refactor(eslint): ♻️ add eslint-plugin-n to eslint configuration (#528)
<!-- 👋 Hi, thanks for sending a PR to template-typescript-node-package! 💖. Please fill out all fields below and make sure each item is true and [x] checked. Otherwise we may not be able to review your PR. --> ## PR Checklist - [x] Addresses an existing open issue: fixes #470 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/template-typescript-node-package/blob/main/.github/CONTRIBUTING.md) were taken ## Overview <!-- Description of what is changed and how the code change does that. --> Added eslint-plugin-n & checked for linting errors. **Note:** Seems perfectionist eslint was not run on `.eslintrc.cjs`, so I did that which changes the order of the objects. --------- Co-authored-by: Josh Goldberg <[email protected]>
1 parent 5ac730f commit 052c41a

File tree

6 files changed

+58
-12
lines changed

6 files changed

+58
-12
lines changed

.eslintrc.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
extends: [
1818
"eslint:recommended",
1919
"plugin:eslint-comments/recommended",
20+
"plugin:n/recommended",
2021
"plugin:perfectionist/recommended-natural",
2122
"plugin:regexp/recommended",
2223
"prettier",
@@ -126,6 +127,12 @@ module.exports = {
126127
// These off/less-strict-by-default rules work well for this repo and we like them on.
127128
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }],
128129
"import/extensions": ["error", "ignorePackages"],
130+
"n/no-missing-import": [
131+
"error",
132+
{
133+
allowModules: ["template-typescript-node-package"],
134+
},
135+
],
129136
"no-only-tests/no-only-tests": "error",
130137

131138
// These on-by-default rules don't work well for this repo and we like them off.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"eslint-plugin-jsdoc": "^46.0.0",
6868
"eslint-plugin-jsonc": "^2.8.0",
6969
"eslint-plugin-markdown": "^3.0.0",
70+
"eslint-plugin-n": "^16.0.0",
7071
"eslint-plugin-no-only-tests": "^3.1.0",
7172
"eslint-plugin-perfectionist": "^1.1.2",
7273
"eslint-plugin-regexp": "^1.15.0",

pnpm-lock.yaml

Lines changed: 37 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hydrate/steps/writing/creation/rootFiles.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = {
4646
extends: [
4747
"eslint:recommended",
4848
"plugin:eslint-comments/recommended",
49+
"plugin:n/recommended",
4950
"plugin:perfectionist/recommended-natural",
5051
"plugin:regexp/recommended",
5152
"prettier",
@@ -148,9 +149,13 @@ module.exports = {
148149
rules: {
149150
// These off/less-strict-by-default rules work well for this repo and we like them on.
150151
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }],
151-
"import/extensions": ["error", "ignorePackages"],${
152-
values.unitTests ? `\n"no-only-tests/no-only-tests": "error",` : ""
153-
}
152+
"import/extensions": ["error", "ignorePackages"],
153+
"n/no-missing-import": [
154+
"error",
155+
{
156+
allowModules: ["template-typescript-node-package"],
157+
},
158+
],${values.unitTests ? `\n"no-only-tests/no-only-tests": "error",` : ""}
154159
155160
// These on-by-default rules don't work well for this repo and we like them off.
156161
"no-case-declarations": "off",

src/shared/getOctokit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export async function getOctokit(
2525
console.error();
2626
console.error(chalk.red((error as Error).message));
2727
console.error();
28-
process.exit(0);
28+
// eslint-disable-next-line n/no-process-exit
29+
process.exit(1);
2930
}
3031

3132
const auth = (await $`gh auth token`).stdout.trim();

src/shared/prompts.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as prompts from "@clack/prompts";
22

3-
export function handleCancel(): never {
3+
export function handleCancel() {
44
prompts.cancel("Operation cancelled. Exiting - maybe another time? 👋");
5-
process.exit(0);
5+
// eslint-disable-next-line n/no-process-exit
6+
process.exit(1);
67
}
78

89
export function handlePromptCancel(

0 commit comments

Comments
 (0)