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

build: fix eslint config #249

Merged
Merged
Changes from all commits
Commits
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
208 changes: 114 additions & 94 deletions eslint.config.mjs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little bit awkward as the entire file got formatted, but apparently thats exactly how the prettier config wants it.

Original file line number Diff line number Diff line change
Expand Up @@ -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"],
},
],
},
},
}];
];