@shayanthenerd/eslint-config
Version:
A modern, flexible ESLint configuration for enforcing best practices and maintaining a consistent coding style
63 lines (61 loc) • 2.03 kB
JavaScript
import { isEnabled } from "../utils/isEnabled.js";
import { defaultOptions } from "../utils/options/defaultOptions.js";
//#region src/rules/typescript.ts
function getTypeScriptRules(options) {
const { typescript } = options.configs;
const { typeDefinitionStyle, methodSignatureStyle } = isEnabled(typescript) ? typescript : defaultOptions.configs.typescript;
const tsRules = {
"no-loop-func": "off",
"no-unused-vars": "off",
"default-param-last": "off",
"prefer-destructuring": "off",
"@typescript-eslint/no-loop-func": "error",
"@typescript-eslint/default-param-last": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/prefer-destructuring": "warn",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-useless-empty-export": "error",
"@typescript-eslint/no-unsafe-type-assertion": "warn",
"@typescript-eslint/prefer-enum-initializers": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/switch-exhaustiveness-check": "warn",
"@typescript-eslint/explicit-module-boundary-types": "warn",
"@typescript-eslint/no-unnecessary-parameter-property-assignment": "warn",
"@typescript-eslint/method-signature-style": ["error", methodSignatureStyle],
"@typescript-eslint/consistent-type-definitions": ["warn", typeDefinitionStyle],
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "variable",
format: [
"camelCase",
"PascalCase",
"UPPER_CASE"
]
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require"
},
{
selector: "enumMember",
format: ["PascalCase"]
},
{
selector: "typeLike",
format: ["PascalCase"],
custom: {
regex: "^(I|T(?!S))[A-Z]",
match: false
}
}
]
};
return tsRules;
}
//#endregion
export { getTypeScriptRules };