Skip to content

Commit

Permalink
feat: much more ESLint config configurability (#867)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #864; fixes #866
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Adds:

- `--exclude-lint-deprecation`
- `--exclude-lint-eslint`
- `--exclude-lint-jsdoc`
- `--exclude-lint-regex`
- `--exclude-lint-strict`
- `--exclude-lint-stylistic`

Assorted cleanups:

* Removes `eslint-config-prettier` since I believe none of the
recommended configs include rules impacted by it (yay!)
* Removes `eslint-plugin-import` as TypeScript's `"moduleResolution":
"NodeNext"` will report on a missing file extension in an import
* As of eslint-community/eslint-plugin-n#24 I
don't think `n/no-missing-import` is buggy enough to need to be disabled
* eslint-community/eslint-plugin-n#84 is still
in effect, but this template doesn't use `paths`.
* Removes the ESLint config comment now that most users are on a simpler
"common" config
* Finally add some high-level unit testing for `createESLintRC` to help
validate the changes
  • Loading branch information
JoshuaKGoldberg committed Sep 21, 2023
1 parent cc0cbaf commit 094b253
Show file tree
Hide file tree
Showing 18 changed files with 430 additions and 268 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module.exports = {
"plugin:perfectionist/recommended-natural",
"plugin:regexp/recommended",
"plugin:vitest/recommended",
"prettier",
],
overrides: [
{
Expand Down Expand Up @@ -128,7 +127,6 @@ module.exports = {
plugins: [
"@typescript-eslint",
"deprecation",
"import",
"jsdoc",
"no-only-tests",
"perfectionist",
Expand All @@ -140,14 +138,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"],
"no-only-tests/no-only-tests": "error",

// These on-by-default rules don't work well for this repo and we like them off.
"n/no-missing-import": "off",
"no-case-declarations": "off",
"no-constant-condition": "off",
"no-inner-declarations": "off",
"no-mixed-spaces-and-tabs": "off",

// Stylistic concerns that don't interfere with Prettier
"@typescript-eslint/padding-line-between-statements": [
Expand Down
6 changes: 6 additions & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ Alternately, you can bypass that prompt by providing any number of the following
- `--exclude-lint-knip`: Don't add Knip to detect unused files, dependencies, and code exports.
- `--exclude-lint-md`: Don't apply linting to `*.md` files.
- `--exclude-lint-package-json`: Don't add npm-package-json-lint to lint for package.json correctness.
- `--exclude-lint-deprecation`: Don't use eslint-plugin-deprecation to report on usage of code marked as `@deprecated`.
- `--exclude-lint-eslint`: Don't use eslint-plugin-eslint-comment to enforce good practices around ESLint comment directives.
- `--exclude-lint-jsdoc`: Don't use eslint-plugin-jsdoc to enforce good practices around JSDoc comments.
- `--exclude-lint-packages`: Don't add a pnpm dedupe workflow to ensure packages aren't duplicated unnecessarily.
- `--exclude-lint-perfectionist`: Don't apply eslint-plugin-perfectionist to ensure imports, keys, and so on are in sorted order.
- `--exclude-lint-regex`: Don't add eslint-plugin-regex to enforce good practices around regular expressions.
- `--exclude-lint-strict`: Don't augment the recommended logical lint rules with typescript-eslint's strict config.
- `--exclude-lint-stylistic`: Don't add stylistic rules such as typescript-eslint's stylistic config.
- `--exclude-lint-spelling`: Don't add cspell to spell check against dictionaries of known words.
- `--exclude-lint-yml`: Don't apply linting and sorting to `*.yaml` and `*.yml` files.
- `--exclude-releases`: Don't add release-it to generate changelogs, package bumps, and publishes based on conventional commits.
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@
"console-fail-test": "^0.2.3",
"cspell": "^7.0.1",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsdoc": "^46.5.0",
"eslint-plugin-jsonc": "^2.9.0",
"eslint-plugin-markdown": "^3.0.1",
Expand Down
213 changes: 1 addition & 212 deletions pnpm-lock.yaml

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

0 comments on commit 094b253

Please sign in to comment.