From e1ccd6c3e5989b94d47fc7eefd547f02037c0908 Mon Sep 17 00:00:00 2001 From: Floyd Haremsa Date: Wed, 29 Jan 2025 14:17:16 +0100 Subject: [PATCH] build: fix eslint config --- eslint.config.mjs | 208 +++++++++++++++++++++++++--------------------- 1 file changed, 114 insertions(+), 94 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index bcae22c..82686e5 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -4,116 +4,136 @@ import unicorn from "eslint-plugin-unicorn"; import globals from "globals"; import tsParser from "@typescript-eslint/parser"; import path from "node:path"; -import { fileURLToPath } from "node:url"; +import {fileURLToPath} from "node:url"; import js from "@eslint/js"; -import { FlatCompat } from "@eslint/eslintrc"; +import {FlatCompat} from "@eslint/eslintrc"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, recommendedConfig: js.configs.recommended, - allConfig: js.configs.all + allConfig: js.configs.all, }); -export default [{ - ignores: [ - "**/jest.config.ts", - "**/node_modules", - "**/node_modules", - "**/commitlint.config.js", - "**/jest.config.js", - "**/.eslintrc.js", - "**/jest.config.ts", - ], -}, ...compat.extends( - "eslint:recommended", - "plugin:@typescript-eslint/recommended-type-checked", - "plugin:@typescript-eslint/stylistic-type-checked", - "plugin:unicorn/recommended", - "prettier", -), { - plugins: { - "@typescript-eslint": typescriptEslint, - "prefer-arrow": preferArrow, - unicorn, +export default [ + { + ignores: [ + "**/jest.config.ts", + "**/node_modules", + "**/commitlint.config.js", + "**/jest.config.js", + "**/.eslintrc.js", + "**/jest.config.ts", + "**/eslint.config.mjs", + ], }, - - languageOptions: { - globals: { - ...globals.node, - ...globals.jest, + ...compat.extends( + "eslint:recommended", + "plugin:@typescript-eslint/recommended-type-checked", + "plugin:@typescript-eslint/stylistic-type-checked", + "plugin:unicorn/recommended", + "prettier" + ), + { + plugins: { + "@typescript-eslint": typescriptEslint, + "prefer-arrow": preferArrow, + unicorn, }, - parser: tsParser, - ecmaVersion: 5, - sourceType: "module", + languageOptions: { + globals: { + ...globals.node, + ...globals.jest, + }, - parserOptions: { - tsconfigRootDir: "/Users/nishanth/project/personal/eslint-plugin-nestjs-typed", - project: ["./tsconfig.lint.json"], - }, - }, + parser: tsParser, + ecmaVersion: 5, + sourceType: "module", - rules: { - "unicorn/filename-case": ["warn", { - cases: { - camelCase: true, - pascalCase: true, + parserOptions: { + tsconfigRootDir: "./", + project: ["./tsconfig.lint.json"], }, - }], + }, - "no-eval": "error", - "unicorn/no-fn-reference-in-iterator": "off", - "unicorn/no-array-for-each": "off", - "unicorn/no-null": "off", - "unicorn/prefer-array-some": "off", - "unicorn/consistent-destructuring": "off", - "unicorn/no-array-reduce": "off", - "unicorn/prefer-spread": "off", - "unicorn/no-array-callback-reference": "off", - "unicorn/consistent-function-scoping": "off", - "unicorn/no-useless-undefined": "off", - "unicorn/prefer-ternary": "off", - "unicorn/prefer-node-protocol": "off", + rules: { + "unicorn/filename-case": [ + "warn", + { + cases: { + camelCase: true, + pascalCase: true, + }, + }, + ], - "unicorn/prevent-abbreviations": ["error", { - allowList: { - Param: true, - Req: true, - Res: true, - }, - }], + "no-eval": "error", + "unicorn/no-fn-reference-in-iterator": "off", + "unicorn/no-array-for-each": "off", + "unicorn/no-null": "off", + "unicorn/prefer-array-some": "off", + "unicorn/consistent-destructuring": "off", + "unicorn/no-array-reduce": "off", + "unicorn/prefer-spread": "off", + "unicorn/no-array-callback-reference": "off", + "unicorn/consistent-function-scoping": "off", + "unicorn/no-useless-undefined": "off", + "unicorn/prefer-ternary": "off", + "unicorn/prefer-node-protocol": "off", - "@typescript-eslint/naming-convention": ["error", { - selector: "default", - format: null, - }, { - selector: "variable", - format: ["PascalCase", "UPPER_CASE"], - types: ["boolean"], - prefix: ["is", "should", "has", "can", "did", "will"], - }, { - selector: "variableLike", - format: ["camelCase", "UPPER_CASE", "PascalCase"], - }, { - selector: "parameter", - format: ["camelCase"], - }, { - selector: "memberLike", - modifiers: ["private"], - format: ["camelCase"], - leadingUnderscore: "forbid", - }, { - selector: "typeLike", - format: ["PascalCase"], - }, { - selector: "property", - modifiers: ["readonly"], - format: ["PascalCase"], - }, { - selector: "enumMember", - format: ["UPPER_CASE"], - }], + "unicorn/prevent-abbreviations": [ + "error", + { + allowList: { + Param: true, + Req: true, + Res: true, + }, + }, + ], + + "@typescript-eslint/naming-convention": [ + "error", + { + selector: "default", + format: null, + }, + { + selector: "variable", + format: ["PascalCase", "UPPER_CASE"], + types: ["boolean"], + prefix: ["is", "should", "has", "can", "did", "will"], + }, + { + selector: "variableLike", + format: ["camelCase", "UPPER_CASE", "PascalCase"], + }, + { + selector: "parameter", + format: ["camelCase"], + }, + { + selector: "memberLike", + modifiers: ["private"], + format: ["camelCase"], + leadingUnderscore: "forbid", + }, + { + selector: "typeLike", + format: ["PascalCase"], + }, + { + selector: "property", + modifiers: ["readonly"], + format: ["PascalCase"], + }, + { + selector: "enumMember", + format: ["UPPER_CASE"], + }, + ], + }, }, -}]; \ No newline at end of file +];