2021-08-12 22:01:54 +00:00
const {
ERROR ,
OFF ,
SUCCESSOR ,
TYPESCRIPT _CONVERSION ,
TYPESCRIPT _EXTENSION ,
UNKNOWN ,
WARN ,
} = require ( 'eslint-config-helpers' ) ;
2021-05-12 06:35:00 +00:00
/** @type { import('eslint').Linter.Config } */
module . exports = {
2021-12-09 01:44:04 +00:00
settings : {
react : {
2023-08-09 22:14:16 +00:00
version : 'detect' ,
2021-12-09 01:44:04 +00:00
} ,
} ,
2021-05-12 06:35:00 +00:00
parser : '@typescript-eslint/parser' ,
parserOptions : {
tsconfigRootDir : _ _dirname ,
ecmaFeatures : {
jsx : true ,
} ,
} ,
extends : [
'plugin:@typescript-eslint/eslint-recommended' ,
'plugin:@typescript-eslint/recommended' ,
2021-05-27 18:00:32 +00:00
'plugin:react/recommended' ,
2021-05-12 06:35:00 +00:00
'plugin:react-hooks/recommended' ,
] ,
plugins : [
'@typescript-eslint' ,
'react' ,
'jest' ,
'html' ,
'json' ,
'filenames' ,
'react-hooks' ,
2021-07-22 23:04:56 +00:00
'import' ,
'simple-import-sort' ,
2021-05-12 06:35:00 +00:00
] ,
globals : {
_ _DEV _ _ : true ,
fail : true ,
NodeJS : true ,
HTMLDivElement : true ,
HTMLElement : true ,
HTMLInputElement : true ,
HTMLSelectElement : true ,
JSX : true ,
} ,
env : {
browser : true ,
commonjs : true ,
es6 : true ,
'jest/globals' : true ,
node : true ,
} ,
overrides : [
{
files : [ '*.js' ] ,
rules : {
2021-08-12 22:01:54 +00:00
'@typescript-eslint/no-var-requires' : OFF ( UNKNOWN ) ,
2021-05-12 06:35:00 +00:00
} ,
} ,
] ,
rules : {
2021-08-12 22:01:54 +00:00
'array-bracket-spacing' : ERROR ,
'brace-style' : SUCCESSOR ( TYPESCRIPT _EXTENSION ) ,
2022-04-13 21:04:29 +00:00
'block-spacing' : ERROR ,
2021-08-12 22:01:54 +00:00
'comma-dangle' : [ ERROR , 'always-multiline' ] ,
'comma-spacing' : ERROR ,
2021-12-08 18:25:28 +00:00
'consistent-return' : OFF ( 'found to be too many false positives' ) ,
2022-04-13 21:04:29 +00:00
'curly' : ERROR ,
2021-08-12 22:01:54 +00:00
'default-case' : ERROR ,
'default-case-last' : ERROR ,
'eol-last' : [ ERROR , 'always' ] ,
'eqeqeq' : [ ERROR , 'smart' ] ,
'arrow-parens' : [ ERROR , 'as-needed' ] ,
'arrow-spacing' : ERROR ,
'keyword-spacing' : SUCCESSOR ( TYPESCRIPT _EXTENSION ) ,
'no-async-promise-executor' : OFF ( UNKNOWN ) ,
'no-case-declarations' : OFF ( UNKNOWN ) ,
'no-duplicate-imports' : OFF ( UNKNOWN ) ,
'no-prototype-builtins' : OFF ( UNKNOWN ) ,
'no-redeclare' : OFF ( UNKNOWN ) ,
'no-unused-vars' : OFF ( UNKNOWN ) ,
'no-use-before-define' : OFF ( UNKNOWN ) ,
'no-var' : ERROR ,
'no-trailing-spaces' : ERROR ,
'no-multiple-empty-lines' : [ ERROR , { 'max' : 1 , 'maxEOF' : 0 } ] ,
'object-curly-spacing' : [ ERROR , 'always' ] ,
'quotes' : OFF ( UNKNOWN ) ,
2021-09-01 14:50:26 +00:00
'semi' : SUCCESSOR ( TYPESCRIPT _EXTENSION ) ,
2022-04-13 21:04:29 +00:00
'space-before-blocks' : ERROR , // TODO: use the @typescript-eslint/space-before-blocks once we typescript-eslint past 5.13
2021-08-12 22:01:54 +00:00
'space-before-function-paren' : [ ERROR , { anonymous : 'never' , named : 'never' , asyncArrow : 'always' } ] ,
'space-infix-ops' : SUCCESSOR ( TYPESCRIPT _EXTENSION ) ,
'space-unary-ops' : ERROR ,
'space-in-parens' : ERROR ,
'spaced-comment' : [ ERROR , 'always' , {
2021-05-12 06:35:00 +00:00
exceptions : [ '/' , '*' , '-' , '* ' ] , // for ASCII art :)
markers : [
'/' , // for TypeScript directives, doxygen, vsdoc, etc. (which use `///`)
'?' , // for Quokka
] ,
} ] ,
2021-07-22 23:04:56 +00:00
2021-08-12 22:01:54 +00:00
'react/no-unescaped-entities' : OFF ( TYPESCRIPT _CONVERSION ) ,
'react/jsx-first-prop-new-line' : [ ERROR , 'multiline' ] ,
'react/jsx-max-props-per-line' : [ ERROR , { maximum : 1 , when : 'multiline' } ] ,
'react/jsx-uses-react' : ERROR ,
'react/jsx-uses-vars' : ERROR ,
'react/jsx-indent-props' : [ ERROR , 2 ] ,
'react/prop-types' : OFF ( UNKNOWN ) ,
'react/function-component-definition' : [ ERROR , {
2023-07-19 13:56:27 +00:00
'namedComponents' : 'arrow-function' ,
2021-08-07 08:03:56 +00:00
'unnamedComponents' : 'arrow-function' ,
} ] ,
2021-08-12 22:01:54 +00:00
'react/jsx-closing-bracket-location' : [ ERROR , 'line-aligned' ] ,
2021-09-15 20:16:04 +00:00
'react/prefer-stateless-function' : ERROR ,
2021-08-12 22:01:54 +00:00
'react/jsx-key' : [ ERROR , { 'checkFragmentShorthand' : true } ] ,
'react/no-array-index-key' : WARN ( UNKNOWN ) ,
'react/self-closing-comp' : ERROR ,
2021-07-22 23:04:56 +00:00
2021-08-12 22:01:54 +00:00
'react-hooks/exhaustive-deps' : [ ERROR , {
2021-08-10 23:57:13 +00:00
// From react-use https://github.com/streamich/react-use/issues/1703#issuecomment-770972824
'additionalHooks' : '^use(Async|AsyncFn|AsyncRetry|Debounce|UpdateEffect|IsomorphicLayoutEffect|DeepCompareEffect|ShallowCompareEffect)$' ,
} ] ,
2021-08-12 22:01:54 +00:00
'react-hooks/rules-of-hooks' : ERROR ,
2021-07-22 23:04:56 +00:00
2021-08-12 22:01:54 +00:00
'@typescript-eslint/array-type' : [ ERROR , { default : 'array' , readonly : 'array' } ] ,
'@typescript-eslint/ban-types' : OFF ( UNKNOWN ) ,
2022-04-13 21:04:29 +00:00
'@typescript-eslint/brace-style' : [ ERROR , '1tbs' ] ,
2021-08-12 22:01:54 +00:00
'@typescript-eslint/consistent-type-definitions' : [ ERROR , 'interface' ] ,
'@typescript-eslint/explicit-module-boundary-types' : OFF ( UNKNOWN ) ,
'@typescript-eslint/keyword-spacing' : ERROR ,
2021-09-01 14:50:26 +00:00
'@typescript-eslint/member-delimiter-style' : ERROR ,
2021-08-12 22:01:54 +00:00
'@typescript-eslint/no-empty-function' : OFF ( UNKNOWN ) ,
2021-09-08 15:38:07 +00:00
'@typescript-eslint/no-empty-interface' : [ ERROR , { 'allowSingleExtends' : true } ] ,
2021-08-12 22:01:54 +00:00
'@typescript-eslint/no-namespace' : [ ERROR , { allowDeclarations : true } ] ,
'@typescript-eslint/no-redeclare' : ERROR ,
'@typescript-eslint/no-unused-vars' : [ ERROR , { ignoreRestSiblings : true } ] ,
'@typescript-eslint/space-infix-ops' : ERROR ,
2021-09-01 14:50:26 +00:00
'@typescript-eslint/semi' : [ ERROR , 'always' ] ,
2021-08-12 22:01:54 +00:00
'@typescript-eslint/quotes' : [ ERROR , 'single' , { avoidEscape : true } ] ,
2021-07-22 23:04:56 +00:00
2021-08-12 22:01:54 +00:00
'simple-import-sort/imports' : ERROR ,
2023-08-09 22:14:16 +00:00
'filenames/match-exported' : OFF ( UNKNOWN ) ,
camelcase : OFF ( UNKNOWN ) ,
'@typescript-eslint/no-use-before-define' : OFF ( TYPESCRIPT _CONVERSION ) ,
'@typescript-eslint/no-explicit-any' : OFF ( TYPESCRIPT _CONVERSION ) ,
'react/no-find-dom-node' : OFF ( UNKNOWN ) ,
'no-restricted-properties' : [ ERROR , {
property : 'openExternal' ,
message : 'use the `window.main.openInBrowser` function instead. see https://security.stackexchange.com/questions/225799/dangers-of-electrons-shell-openexternal-on-untrusted-content for more information.' ,
} ] ,
2021-05-12 06:35:00 +00:00
} ,
} ;