2024-05-24 14:37:42 +00:00
import tseslint from '@typescript-eslint/eslint-plugin' ;
2024-10-20 01:44:36 +00:00
import stylisticTs from '@stylistic/eslint-plugin-ts' ;
2024-05-24 14:37:42 +00:00
import parser from '@typescript-eslint/parser' ;
2024-09-10 20:34:50 +00:00
import importX from 'eslint-plugin-import-x' ;
2024-05-24 14:37:42 +00:00
export default [
{
files : [ "src/**/*.{ts,tsx,js,jsx}" ] ,
ignores : [ "dist/*" , "build/*" , "coverage/*" , "public/*" , ".github/*" , "node_modules/*" , ".vscode/*" ] ,
languageOptions : {
parser : parser
} ,
plugins : {
2024-09-10 20:34:50 +00:00
"import-x" : importX ,
2024-07-30 04:29:34 +00:00
'@stylistic/ts' : stylisticTs ,
2024-05-24 14:37:42 +00:00
'@typescript-eslint' : tseslint
} ,
rules : {
2024-10-20 01:44:36 +00:00
"eqeqeq" : [ "error" , "always" ] , // Enforces the use of `===` and `!==` instead of `==` and `!=`
"indent" : [ "error" , 2 , { "SwitchCase" : 1 } ] , // Enforces a 2-space indentation, enforces indentation of `case ...:` statements
2024-05-24 14:37:42 +00:00
"quotes" : [ "error" , "double" ] , // Enforces the use of double quotes for strings
2024-10-20 01:44:36 +00:00
"no-var" : "error" , // Disallows the use of `var`, enforcing `let` or `const` instead
"prefer-const" : "error" , // Enforces the use of `const` for variables that are never reassigned
2024-05-24 14:37:42 +00:00
"no-undef" : "off" , // Disables the rule that disallows the use of undeclared variables (TypeScript handles this)
"@typescript-eslint/no-unused-vars" : [ "error" , {
"args" : "none" , // Allows unused function parameters. Useful for functions with specific signatures where not all parameters are always used.
2024-10-20 01:44:36 +00:00
"ignoreRestSiblings" : true // Allows unused variables that are part of a rest property in object destructuring. Useful for excluding certain properties from an object while using the others.
2024-05-24 14:37:42 +00:00
} ] ,
"eol-last" : [ "error" , "always" ] , // Enforces at least one newline at the end of files
2024-07-30 04:29:34 +00:00
"@stylistic/ts/semi" : [ "error" , "always" ] , // Requires semicolons for TypeScript-specific syntax
2024-05-24 14:37:42 +00:00
"semi" : "off" , // Disables the general semi rule for TypeScript files
"no-extra-semi" : [ "error" ] , // Disallows unnecessary semicolons for TypeScript-specific syntax
"brace-style" : "off" , // Note: you must disable the base rule as it can report incorrect errors
"curly" : [ "error" , "all" ] , // Enforces the use of curly braces for all control statements
2024-10-20 01:44:36 +00:00
"@stylistic/ts/brace-style" : [ "error" , "1tbs" ] , // Enforces the following brace style: https://eslint.style/rules/js/brace-style#_1tbs
2024-05-24 14:37:42 +00:00
"no-trailing-spaces" : [ "error" , { // Disallows trailing whitespace at the end of lines
"skipBlankLines" : false , // Enforces the rule even on blank lines
"ignoreComments" : false // Enforces the rule on lines containing comments
} ] ,
"space-before-blocks" : [ "error" , "always" ] , // Enforces a space before blocks
2024-08-23 08:36:10 +00:00
"keyword-spacing" : [ "error" , { "before" : true , "after" : true } ] , // Enforces spacing before and after keywords
2024-10-20 01:44:36 +00:00
"comma-spacing" : [ "error" , { "before" : false , "after" : true } ] , // Enforces spacing after commas
2024-09-10 20:34:50 +00:00
"import-x/extensions" : [ "error" , "never" , { "json" : "always" } ] , // Enforces no extension for imports unless json
2024-10-04 05:08:31 +00:00
"array-bracket-spacing" : [ "error" , "always" , { "objectsInArrays" : false , "arraysInArrays" : false } ] , // Enforces consistent spacing inside array brackets
"object-curly-spacing" : [ "error" , "always" , { "arraysInObjects" : false , "objectsInObjects" : false } ] , // Enforces consistent spacing inside braces of object literals, destructuring assignments, and import/export specifiers
"computed-property-spacing" : [ "error" , "never" ] , // Enforces consistent spacing inside computed property brackets
"space-infix-ops" : [ "error" , { "int32Hint" : false } ] , // Enforces spacing around infix operators
"no-multiple-empty-lines" : [ "error" , { "max" : 2 , "maxEOF" : 1 , "maxBOF" : 0 } ] , // Disallows multiple empty lines
2024-05-24 14:37:42 +00:00
}
}
2024-05-24 14:41:46 +00:00
]