generated from nhcarrigan/template
### Explanation _No response_ ### Issue _No response_ ### Attestations - [x] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/) - [x] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/). - [x] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/). ### Dependencies - [x] I have pinned the dependencies to a specific patch version. ### Style - [x] I have run the linter and resolved any errors. - [x] My pull request uses an appropriate title, matching the conventional commit standards. - [x] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request. ### Tests - [x] My contribution adds new code, and I have added tests to cover it. - [x] My contribution modifies existing code, and I have updated the tests to reflect these changes. - [x] All new and existing tests pass locally with my changes. - [x] Code coverage remains at or above the configured threshold. ### Documentation _No response_ ### Versioning Minor - My pull request introduces a new non-breaking feature. Reviewed-on: https://codeberg.org/nhcarrigan/eslint-config/pulls/11 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
215 lines
7.0 KiB
TypeScript
215 lines
7.0 KiB
TypeScript
/**
|
|
* @copyright nhcarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
|
|
import { fixupPluginRules } from "@eslint/compat";
|
|
import comments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
import stylistic from "@stylistic/eslint-plugin";
|
|
import tslint from "@typescript-eslint/eslint-plugin";
|
|
import parser from "@typescript-eslint/parser";
|
|
import vitest from "@vitest/eslint-plugin";
|
|
import deprecation from "eslint-plugin-deprecation";
|
|
import importPlugin from "eslint-plugin-import";
|
|
import jsdoc from "eslint-plugin-jsdoc";
|
|
import playwright from "eslint-plugin-playwright";
|
|
import react from "eslint-plugin-react";
|
|
import sortKeysFix from "eslint-plugin-sort-keys-fix";
|
|
import unicorn from "eslint-plugin-unicorn";
|
|
import globals from "globals";
|
|
import { commentsRules } from "./rules/comments.js";
|
|
import { deprecationRules } from "./rules/deprecation.js";
|
|
import { disabledEslintRules, eslintRules } from "./rules/eslint.js";
|
|
import { importRules } from "./rules/import.js";
|
|
import { jsdocRules } from "./rules/jsdoc.js";
|
|
import { playwrightRules } from "./rules/playwright.js";
|
|
import { reactRules } from "./rules/react.js";
|
|
import { sortKeysFixRules } from "./rules/sortKeysFix.js";
|
|
import { stylisticRules } from "./rules/stylistic.js";
|
|
import { typescriptEslintRules, typescriptEslintRulesWithTypes }
|
|
from "./rules/typescriptEslint.js";
|
|
import { unicornRules } from "./rules/unicorn.js";
|
|
import { vitestRules } from "./rules/vitest.js";
|
|
import type { ESLint, Linter } from "eslint";
|
|
|
|
const config: Array<Linter.Config> = [
|
|
// #region Typescript Config
|
|
{
|
|
files: [ "src/**/*.ts" ],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
},
|
|
parser: parser,
|
|
parserOptions: {
|
|
ecmaVersion: 11,
|
|
project: true,
|
|
sourceType: "module",
|
|
tsconfigRootDir: process.cwd(),
|
|
},
|
|
},
|
|
plugins: {
|
|
// @ts-expect-error It's a config. It's just not the narrow config. SMH.
|
|
"@typescript-eslint": tslint,
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Not unsafe, just not typed.
|
|
"comments": comments,
|
|
// @ts-expect-error They haven't typedef this yet because it technically doesn't support eslint9
|
|
"deprecation": fixupPluginRules(deprecation),
|
|
"import": fixupPluginRules(importPlugin as ESLint.Plugin),
|
|
"jsdoc": jsdoc,
|
|
"sort-keys-fix": sortKeysFix as ESLint.Plugin,
|
|
// @ts-expect-error They haven't typedef this yet because it technically doesn't support eslint9
|
|
"stylistic": fixupPluginRules(stylistic),
|
|
"unicorn": unicorn,
|
|
},
|
|
rules: {
|
|
...eslintRules,
|
|
...disabledEslintRules,
|
|
...typescriptEslintRules,
|
|
...typescriptEslintRulesWithTypes,
|
|
...importRules,
|
|
...jsdocRules,
|
|
...deprecationRules,
|
|
...stylisticRules,
|
|
...unicornRules,
|
|
...sortKeysFixRules,
|
|
...commentsRules,
|
|
},
|
|
},
|
|
// #endregion
|
|
|
|
// #region Vitest Config
|
|
{
|
|
files: [ "test/**/*.spec.ts" ],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
},
|
|
parser: parser,
|
|
parserOptions: {
|
|
ecmaVersion: 11,
|
|
sourceType: "module",
|
|
},
|
|
},
|
|
plugins: {
|
|
// @ts-expect-error It's a config. It's just not the narrow config. SMH.
|
|
"@typescript-eslint": tslint,
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Not unsafe, just not typed.
|
|
"comments": comments,
|
|
"import": fixupPluginRules(importPlugin as ESLint.Plugin),
|
|
"jsdoc": jsdoc,
|
|
"sort-keys-fix": sortKeysFix as ESLint.Plugin,
|
|
// @ts-expect-error They haven't typedef this yet because it technically doesn't support eslint9
|
|
"stylistic": fixupPluginRules(stylistic),
|
|
"unicorn": unicorn,
|
|
"vitest": vitest,
|
|
},
|
|
rules: {
|
|
...eslintRules,
|
|
...disabledEslintRules,
|
|
...typescriptEslintRules,
|
|
...vitestRules,
|
|
...importRules,
|
|
...jsdocRules,
|
|
...stylisticRules,
|
|
...unicornRules,
|
|
...sortKeysFixRules,
|
|
...commentsRules,
|
|
},
|
|
},
|
|
// #endregion
|
|
|
|
// #region Playwright Config
|
|
{
|
|
files: [ "e2e/**/*.spec.ts" ],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
},
|
|
parser: parser,
|
|
parserOptions: {
|
|
ecmaVersion: 11,
|
|
sourceType: "module",
|
|
},
|
|
},
|
|
plugins: {
|
|
// @ts-expect-error It's a config. It's just not the narrow config. SMH.
|
|
"@typescript-eslint": tslint,
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Not unsafe, just not typed.
|
|
"comments": comments,
|
|
"import": fixupPluginRules(importPlugin as ESLint.Plugin),
|
|
"jsdoc": jsdoc,
|
|
"playwright": playwright,
|
|
"sort-keys-fix": sortKeysFix as ESLint.Plugin,
|
|
// @ts-expect-error They haven't typedef this yet because it technically doesn't support eslint9
|
|
"stylistic": fixupPluginRules(stylistic),
|
|
"unicorn": unicorn,
|
|
},
|
|
rules: {
|
|
...eslintRules,
|
|
...disabledEslintRules,
|
|
...typescriptEslintRules,
|
|
...playwrightRules,
|
|
...importRules,
|
|
...jsdocRules,
|
|
...stylisticRules,
|
|
...unicornRules,
|
|
...sortKeysFixRules,
|
|
...commentsRules,
|
|
},
|
|
},
|
|
// #endregion
|
|
|
|
// #region React Config
|
|
{
|
|
files: [ "src/**/*.tsx" ],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.browser,
|
|
},
|
|
parser: parser,
|
|
parserOptions: {
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
ecmaVersion: 11,
|
|
project: true,
|
|
sourceType: "module",
|
|
tsconfigRootDir: process.cwd(),
|
|
},
|
|
},
|
|
plugins: {
|
|
// @ts-expect-error It's a config. It's just not the narrow config. SMH.
|
|
"@typescript-eslint": tslint,
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Not unsafe, just not typed.
|
|
"comments": comments,
|
|
// @ts-expect-error They haven't typedef this yet because it technically doesn't support eslint9
|
|
"deprecation": fixupPluginRules(deprecation),
|
|
"import": fixupPluginRules(importPlugin as ESLint.Plugin),
|
|
"jsdoc": jsdoc,
|
|
"react": react as ESLint.Plugin,
|
|
"sort-keys-fix": sortKeysFix as ESLint.Plugin,
|
|
// @ts-expect-error They haven't typedef this yet because it technically doesn't support eslint9
|
|
"stylistic": fixupPluginRules(stylistic),
|
|
"unicorn": unicorn,
|
|
},
|
|
rules: {
|
|
...eslintRules,
|
|
...disabledEslintRules,
|
|
...typescriptEslintRules,
|
|
...typescriptEslintRulesWithTypes,
|
|
...importRules,
|
|
...jsdocRules,
|
|
...deprecationRules,
|
|
...stylisticRules,
|
|
...unicornRules,
|
|
...sortKeysFixRules,
|
|
...reactRules,
|
|
...commentsRules,
|
|
},
|
|
},
|
|
];
|
|
|
|
export default config;
|