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

feat: use ESLint Flat Config #1457

Merged
merged 26 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1ab526b
feat: use ESLint Flat Config
JoshuaKGoldberg Apr 10, 2024
1e2a1d4
Merge branch 'main'
JoshuaKGoldberg Apr 10, 2024
af62c92
Fix lint:knip
JoshuaKGoldberg Apr 10, 2024
73710f9
Fix lint:spelling
JoshuaKGoldberg Apr 10, 2024
06a899b
Merge branch 'main'
JoshuaKGoldberg Apr 10, 2024
831aa27
createESLintConfig
JoshuaKGoldberg Apr 10, 2024
6142399
Fix lint
JoshuaKGoldberg Apr 10, 2024
3b96ebc
Touchups for generated json files
JoshuaKGoldberg Apr 10, 2024
a2f4342
lint --fix
JoshuaKGoldberg Apr 10, 2024
e11b802
endlines
JoshuaKGoldberg Apr 10, 2024
1e2dd34
Snapshots
JoshuaKGoldberg Apr 10, 2024
6a1c5c0
One little line difference
JoshuaKGoldberg Apr 10, 2024
4706238
Merge branch 'main'
JoshuaKGoldberg Apr 15, 2024
feb5098
Simplified a good bit with extends
JoshuaKGoldberg Apr 15, 2024
7dabb15
Merge branch 'main'
JoshuaKGoldberg Apr 15, 2024
2540957
Fixed up snapshots
JoshuaKGoldberg Apr 15, 2024
3a36d4d
...and this too
JoshuaKGoldberg Apr 15, 2024
c0b8422
Updated migration snapshot to remove cruft again
JoshuaKGoldberg Apr 15, 2024
55238c8
lol deprecation
JoshuaKGoldberg Apr 15, 2024
e47eac4
Merge branch 'main'
JoshuaKGoldberg Apr 15, 2024
80395f1
Merge branch 'main' into eslint-9-flat-config
JoshuaKGoldberg Apr 15, 2024
eaa002b
Finished removing deprecation
JoshuaKGoldberg Apr 15, 2024
d0b6538
Merge branch 'main' into eslint-9-flat-config
JoshuaKGoldberg Apr 15, 2024
7ee976c
Disable type-checked rules in .md/.ts
JoshuaKGoldberg Apr 25, 2024
3642a56
extends is an array
JoshuaKGoldberg Apr 25, 2024
4d39414
Remove a couple of dependencies
JoshuaKGoldberg Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 0 additions & 166 deletions .eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"yaml"
],
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],
"eslint.useFlatConfig": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"precommit",
"quickstart",
"tada",
"tseslint",
"tsup",
"vitest"
]
Expand Down
163 changes: 163 additions & 0 deletions eslint.config.js
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
👋 Hi! This ESLint configuration contains a lot more stuff than many repos'!
You can read from it to see all sorts of linting goodness, but don't worry -
it's not something you need to exhaustively understand immediately. 💙

If you're interested in learning more, see the 'getting started' docs on:
- ESLint: https://eslint.org
- typescript-eslint: https://typescript-eslint.io
*/

import eslint from "@eslint/js";
import comments from "@eslint-community/eslint-plugin-eslint-comments/configs";
import jsdoc from "eslint-plugin-jsdoc";
import jsonc from "eslint-plugin-jsonc";
import markdown from "eslint-plugin-markdown";
import n from "eslint-plugin-n";
import packageJson from "eslint-plugin-package-json/configs/recommended";
import perfectionistNatural from "eslint-plugin-perfectionist/configs/recommended-natural";
import * as regexp from "eslint-plugin-regexp";
import vitest from "eslint-plugin-vitest";
import yml from "eslint-plugin-yml";
import tseslint from "typescript-eslint";

export default tseslint.config(
{
ignores: [
"coverage*",
"lib",
"node_modules",
"pnpm-lock.yaml",
"**/*.snap",
],
},
{
linterOptions: {
reportUnusedDisableDirectives: "error",
},
},
eslint.configs.recommended,
...jsonc.configs["flat/recommended-with-json"],
...markdown.configs.recommended,
...yml.configs["flat/recommended"],
...yml.configs["flat/prettier"],
comments.recommended,
jsdoc.configs["flat/recommended-typescript-error"],
n.configs["flat/recommended"],
packageJson,
perfectionistNatural,
regexp.configs["flat/recommended"],
...tseslint.config({
extends: [
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
files: ["**/*.js", "**/*.ts"],
languageOptions: {
parserOptions: {
EXPERIMENTAL_useProjectService: {
allowDefaultProjectForFiles: ["./*.*s", "eslint.config.js"],
defaultProject: "./tsconfig.json",
},
},
},
rules: {
// These off-by-default rules work well for this repo and we like them on.
"jsdoc/informative-docs": "error",
"logical-assignment-operators": [
"error",
"always",
{ enforceForIfStatements: true },
],
"operator-assignment": "error",

// These on-by-default rules don't work well for this repo and we like them off.
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param": "off",
"jsdoc/require-property": "off",
"jsdoc/require-returns": "off",
"no-constant-condition": "off",

// These on-by-default rules work well for this repo if configured
"@typescript-eslint/no-unnecessary-condition": [
"error",
{
allowConstantLoopConditions: true,
},
],
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "all" }],
"@typescript-eslint/prefer-nullish-coalescing": [
"error",
{ ignorePrimitives: true },
],
"@typescript-eslint/restrict-template-expressions": [
"error",
{ allowBoolean: true, allowNullish: true, allowNumber: true },
],
"perfectionist/sort-objects": [
"error",
{
order: "asc",
"partition-by-comment": true,
type: "natural",
},
],

// Stylistic concerns that don't interfere with Prettier
"no-useless-rename": "error",
"object-shorthand": "error",
},
}),
{
files: ["*.jsonc"],
rules: {
"jsonc/comma-dangle": "off",
"jsonc/no-comments": "off",
"jsonc/sort-keys": "error",
},
},
{
extends: [tseslint.configs.disableTypeChecked],
files: ["**/*.md/*.ts"],
rules: {
"n/no-missing-import": [
"error",
{ allowModules: ["create-typescript-app"] },
],
},
},
{
files: ["**/*.test.*"],
languageOptions: {
globals: vitest.environments.env.globals,
},
plugins: { vitest },
rules: {
...vitest.configs.recommended.rules,

// These on-by-default rules aren't useful in test files.
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
},
},
{
files: ["**/*.{yml,yaml}"],
rules: {
"yml/file-extension": ["error", { extension: "yml" }],
"yml/sort-keys": [
"error",
{
order: { type: "asc" },
pathPattern: "^.*$",
},
],
"yml/sort-sequence-values": [
"error",
{
order: { type: "asc" },
pathPattern: "^.*$",
},
],
},
},
);
Loading
Loading