Skip to content

Commit

Permalink
fix: update to flat config and removed redundant lint stage config (#234
Browse files Browse the repository at this point in the history
)
  • Loading branch information
darraghoriordan authored Jan 12, 2025
2 parents 695cc8a + 9cdd2ee commit df95ef4
Show file tree
Hide file tree
Showing 6 changed files with 1,138 additions and 1,008 deletions.
98 changes: 0 additions & 98 deletions .eslintrc.js

This file was deleted.

3 changes: 2 additions & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{

"*.ts": [
"prettier --parser typescript --write","npx eslint -c .eslintrc.js --ext .ts --no-error-on-unmatched-pattern --no-ignore --max-warnings 0"
"prettier --parser typescript --write",
"npx eslint --no-error-on-unmatched-pattern --no-ignore --max-warnings 0 ./src/**/*.ts"
]
}
119 changes: 119 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import preferArrow from "eslint-plugin-prefer-arrow";
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 js from "@eslint/js";
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
});

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,
},

languageOptions: {
globals: {
...globals.node,
...globals.jest,
},

parser: tsParser,
ecmaVersion: 5,
sourceType: "module",

parserOptions: {
tsconfigRootDir: "/Users/nishanth/project/personal/eslint-plugin-nestjs-typed",
project: ["./tsconfig.lint.json"],
},
},

rules: {
"unicorn/filename-case": ["warn", {
cases: {
camelCase: true,
pascalCase: 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",

"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"],
}],
},
}];
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"clean": "rm -Rf ./dist/",
"build:ci": "npm run build",
"build": "npm run clean && mkdir ./dist && tsc --project tsconfig.build.json",
"lint": "npx eslint -c .eslintrc.js --ext .ts src --no-error-on-unmatched-pattern --no-ignore",
"lint": "npx eslint --no-error-on-unmatched-pattern --no-ignore ./src/**/*.ts",
"test": "export NODE_OPTIONS=\"--max-old-space-size=8192\" && npx jest --runInBand --colors --reporters=default --no-cache --coverage=false --silent=false -c jest.config.ts",
"pre-commit": "npx lint-staged",
"prettier": "prettier --write src/*",
Expand Down Expand Up @@ -51,6 +51,8 @@
"devDependencies": {
"@commitlint/cli": "19.6.1",
"@commitlint/config-conventional": "19.6.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.17.0",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/exec": "6.0.3",
"@types/eslint": "9.6.1",
Expand All @@ -64,6 +66,7 @@
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-unicorn": "56.0.1",
"globals": "^15.14.0",
"husky": "9.1.7",
"jest": "29.7.0",
"jest-create-mock-instance": "2.0.0",
Expand All @@ -89,9 +92,5 @@
"lint",
"style"
],
"license": "ISC",
"lint-staged": {
"*.ts": "eslint --cache --fix",
"*.{ts,js,css,md}": "prettier --write"
}
"license": "ISC"
}
2 changes: 1 addition & 1 deletion src/fixtures/NonFactoryDecorator.stub.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unused-vars */
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function NonFactoryDecorator(constructor: Function) {
return;
}
Loading

0 comments on commit df95ef4

Please sign in to comment.