2019-07-29 12:55:39 +02:00
|
|
|
module.exports = {
|
2020-12-28 13:48:47 +02:00
|
|
|
'root': true,
|
2019-07-29 12:55:39 +02:00
|
|
|
'env': {
|
|
|
|
'browser': true,
|
|
|
|
'es6': true,
|
|
|
|
'node': true,
|
|
|
|
},
|
2020-08-05 00:00:11 +02:00
|
|
|
'parser': '@typescript-eslint/parser',
|
2019-07-30 09:35:42 +02:00
|
|
|
'extends': ['eslint:recommended'],
|
2020-08-05 00:00:11 +02:00
|
|
|
'settings': {
|
2020-01-29 20:03:55 +02:00
|
|
|
'react': {
|
|
|
|
'version': '16.12',
|
|
|
|
},
|
|
|
|
},
|
2019-07-29 12:55:39 +02:00
|
|
|
'globals': {
|
|
|
|
'Atomics': 'readonly',
|
2019-07-30 09:35:42 +02:00
|
|
|
'SharedArrayBuffer': 'readonly',
|
|
|
|
|
2020-11-19 14:44:20 +02:00
|
|
|
// Jest variables
|
|
|
|
'test': 'readonly',
|
2019-07-30 09:35:42 +02:00
|
|
|
'expect': 'readonly',
|
|
|
|
'describe': 'readonly',
|
|
|
|
'it': 'readonly',
|
2020-02-22 13:25:16 +02:00
|
|
|
'beforeAll': 'readonly',
|
|
|
|
'afterAll': 'readonly',
|
2019-07-30 09:35:42 +02:00
|
|
|
'beforeEach': 'readonly',
|
2020-02-22 13:25:16 +02:00
|
|
|
'afterEach': 'readonly',
|
2020-12-01 20:05:24 +02:00
|
|
|
'jest': 'readonly',
|
2020-11-13 19:09:28 +02:00
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
// React Native variables
|
|
|
|
'__DEV__': 'readonly',
|
|
|
|
|
|
|
|
// Clipper variables
|
|
|
|
'browserSupportsPromises_': true,
|
|
|
|
'chrome': 'readonly',
|
|
|
|
'browser': 'readonly',
|
2020-03-10 01:24:57 +02:00
|
|
|
|
2020-12-28 13:48:47 +02:00
|
|
|
// Server admin UI global variables
|
|
|
|
'onDocumentReady': 'readonly',
|
2021-07-11 16:04:01 +02:00
|
|
|
'setupPasswordStrengthHandler': 'readonly',
|
|
|
|
'$': 'readonly',
|
|
|
|
'zxcvbn': 'readonly',
|
2020-12-28 13:48:47 +02:00
|
|
|
|
2020-03-10 01:24:57 +02:00
|
|
|
'tinymce': 'readonly',
|
2019-07-29 12:55:39 +02:00
|
|
|
},
|
|
|
|
'parserOptions': {
|
|
|
|
'ecmaVersion': 2018,
|
2020-08-05 00:00:11 +02:00
|
|
|
'ecmaFeatures': {
|
|
|
|
'jsx': true,
|
|
|
|
},
|
|
|
|
'sourceType': 'module',
|
2019-07-29 12:55:39 +02:00
|
|
|
},
|
|
|
|
'rules': {
|
2019-09-30 00:01:10 +02:00
|
|
|
// -------------------------------
|
|
|
|
// Code correctness
|
|
|
|
// -------------------------------
|
2020-08-05 00:00:11 +02:00
|
|
|
'react/jsx-uses-react': 'error',
|
|
|
|
'react/jsx-uses-vars': 'error',
|
2020-10-09 19:35:46 +02:00
|
|
|
'no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }],
|
|
|
|
'@typescript-eslint/no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }],
|
|
|
|
'@typescript-eslint/explicit-member-accessibility': 'off',
|
2020-08-05 00:00:11 +02:00
|
|
|
'no-constant-condition': 0,
|
|
|
|
'no-prototype-builtins': 0,
|
2019-09-30 00:01:10 +02:00
|
|
|
// This error is always a false positive so far since it detects
|
|
|
|
// possible race conditions in contexts where we know it cannot happen.
|
2020-08-05 00:00:11 +02:00
|
|
|
'require-atomic-updates': 0,
|
|
|
|
'prefer-const': ['error'],
|
|
|
|
'no-var': ['error'],
|
|
|
|
'no-new-func': ['error'],
|
|
|
|
'import/prefer-default-export': ['error'],
|
2020-12-30 13:51:43 +02:00
|
|
|
|
|
|
|
// This rule should not be enabled since it matters in what order
|
|
|
|
// imports are done, in particular in relation to the shim.setReact
|
|
|
|
// call, which should be done first, but this rule might move it down.
|
|
|
|
// 'import/first': ['error'],
|
|
|
|
|
2020-08-05 00:00:11 +02:00
|
|
|
'no-array-constructor': ['error'],
|
|
|
|
'radix': ['error'],
|
2022-07-23 09:31:32 +02:00
|
|
|
'eqeqeq': ['error', 'always'],
|
2020-01-29 19:54:25 +02:00
|
|
|
|
2020-08-06 01:16:51 +02:00
|
|
|
// Warn only for now because fixing everything would take too much
|
|
|
|
// refactoring, but new code should try to stick to it.
|
2021-05-16 15:21:55 +02:00
|
|
|
// 'complexity': ['warn', { max: 10 }],
|
2020-08-06 01:16:51 +02:00
|
|
|
|
2020-02-27 02:20:55 +02:00
|
|
|
// Checks rules of Hooks
|
2022-08-19 13:10:04 +02:00
|
|
|
'@seiyab/react-hooks/rules-of-hooks': 'error',
|
|
|
|
'@seiyab/react-hooks/exhaustive-deps': ['error', { 'ignoreThisDependency': 'props' }],
|
|
|
|
|
2020-02-27 02:20:55 +02:00
|
|
|
// Checks effect dependencies
|
2020-03-14 01:46:14 +02:00
|
|
|
// Disable because of this: https://github.com/facebook/react/issues/16265
|
|
|
|
// "react-hooks/exhaustive-deps": "warn",
|
2020-02-27 02:20:55 +02:00
|
|
|
|
2022-09-30 18:23:14 +02:00
|
|
|
'promise/prefer-await-to-then': 'error',
|
|
|
|
|
2019-09-30 00:01:10 +02:00
|
|
|
// -------------------------------
|
|
|
|
// Formatting
|
|
|
|
// -------------------------------
|
2020-08-05 00:00:11 +02:00
|
|
|
'space-in-parens': ['error', 'never'],
|
|
|
|
'space-infix-ops': ['error'],
|
|
|
|
'curly': ['error', 'multi-line', 'consistent'],
|
|
|
|
'semi': ['error', 'always'],
|
|
|
|
'eol-last': ['error', 'always'],
|
|
|
|
'quotes': ['error', 'single'],
|
|
|
|
'indent': ['error', 'tab'],
|
|
|
|
'comma-dangle': ['error', {
|
|
|
|
'arrays': 'always-multiline',
|
|
|
|
'objects': 'always-multiline',
|
|
|
|
'imports': 'always-multiline',
|
|
|
|
'exports': 'always-multiline',
|
|
|
|
'functions': 'never',
|
|
|
|
}],
|
|
|
|
'no-trailing-spaces': 'error',
|
|
|
|
'linebreak-style': ['error', 'unix'],
|
|
|
|
'prefer-template': ['error'],
|
|
|
|
'template-curly-spacing': ['error', 'never'],
|
|
|
|
'object-curly-spacing': ['error', 'always'],
|
|
|
|
'array-bracket-spacing': ['error', 'never'],
|
|
|
|
'key-spacing': ['error', {
|
|
|
|
'beforeColon': false,
|
|
|
|
'afterColon': true,
|
|
|
|
'mode': 'strict',
|
2019-09-30 00:01:10 +02:00
|
|
|
}],
|
2020-08-05 00:00:11 +02:00
|
|
|
'block-spacing': ['error'],
|
|
|
|
'brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
|
|
|
|
'no-spaced-func': ['error'],
|
|
|
|
'func-call-spacing': ['error'],
|
|
|
|
'space-before-function-paren': ['error', {
|
|
|
|
'anonymous': 'never',
|
|
|
|
'named': 'never',
|
|
|
|
'asyncArrow': 'always',
|
2019-10-09 21:24:07 +02:00
|
|
|
}],
|
2020-08-05 00:00:11 +02:00
|
|
|
'multiline-comment-style': ['error', 'separate-lines'],
|
|
|
|
'space-before-blocks': 'error',
|
|
|
|
'spaced-comment': ['error', 'always'],
|
|
|
|
'keyword-spacing': ['error', { 'before': true, 'after': true }],
|
2021-01-23 17:51:19 +02:00
|
|
|
'no-multi-spaces': ['error'],
|
2019-07-29 12:55:39 +02:00
|
|
|
},
|
2020-08-05 00:00:11 +02:00
|
|
|
'plugins': [
|
|
|
|
'react',
|
|
|
|
'@typescript-eslint',
|
2022-08-19 13:10:04 +02:00
|
|
|
// Need to use a fork of the official rules of hooks because of this bug:
|
|
|
|
// https://github.com/facebook/react/issues/16265
|
|
|
|
'@seiyab/eslint-plugin-react-hooks',
|
|
|
|
// 'react-hooks',
|
2020-08-05 00:00:11 +02:00
|
|
|
'import',
|
2022-09-30 18:23:14 +02:00
|
|
|
'promise',
|
2019-07-29 12:55:39 +02:00
|
|
|
],
|
2020-10-09 19:35:46 +02:00
|
|
|
'overrides': [
|
|
|
|
{
|
|
|
|
// enable the rule specifically for TypeScript files
|
|
|
|
'files': ['*.ts', '*.tsx'],
|
2020-11-25 16:40:25 +02:00
|
|
|
'parserOptions': {
|
|
|
|
// Required for @typescript-eslint/no-floating-promises
|
|
|
|
'project': './tsconfig.eslint.json',
|
|
|
|
},
|
2020-10-09 19:35:46 +02:00
|
|
|
'rules': {
|
|
|
|
// Warn only because it would make it difficult to convert JS classes to TypeScript, unless we
|
|
|
|
// make everything public which is not great. New code however should specify member accessibility.
|
|
|
|
'@typescript-eslint/explicit-member-accessibility': ['warn'],
|
2020-11-12 21:23:54 +02:00
|
|
|
'@typescript-eslint/type-annotation-spacing': ['error', { 'before': false, 'after': true }],
|
|
|
|
'@typescript-eslint/comma-dangle': ['error', {
|
|
|
|
'arrays': 'always-multiline',
|
|
|
|
'objects': 'always-multiline',
|
|
|
|
'imports': 'always-multiline',
|
|
|
|
'exports': 'always-multiline',
|
|
|
|
'enums': 'always-multiline',
|
|
|
|
'generics': 'always-multiline',
|
|
|
|
'tuples': 'always-multiline',
|
|
|
|
'functions': 'never',
|
|
|
|
}],
|
2020-11-12 21:29:22 +02:00
|
|
|
'@typescript-eslint/semi': ['error', 'always'],
|
|
|
|
'@typescript-eslint/member-delimiter-style': ['error', {
|
|
|
|
'multiline': {
|
|
|
|
'delimiter': 'semi',
|
|
|
|
'requireLast': true,
|
|
|
|
},
|
|
|
|
'singleline': {
|
|
|
|
'delimiter': 'semi',
|
|
|
|
'requireLast': false,
|
|
|
|
},
|
|
|
|
}],
|
2020-11-25 16:40:25 +02:00
|
|
|
'@typescript-eslint/no-floating-promises': ['error'],
|
2021-08-18 17:21:48 +02:00
|
|
|
'@typescript-eslint/naming-convention': ['error',
|
|
|
|
// Naming conventions over the codebase is very inconsistent
|
|
|
|
// unfortunately and fixing it would be way too much work.
|
|
|
|
// In general, we use "strictCamelCase" for variable names.
|
|
|
|
|
|
|
|
// {
|
|
|
|
// selector: 'default',
|
|
|
|
// format: ['StrictPascalCase', 'strictCamelCase', 'snake_case', 'UPPER_CASE'],
|
|
|
|
// leadingUnderscore: 'allow',
|
|
|
|
// trailingUnderscore: 'allow',
|
|
|
|
// },
|
2021-10-03 17:00:49 +02:00
|
|
|
|
|
|
|
// Each rule below is made of two blocks: first the rule we
|
|
|
|
// actually want, and below exceptions to the rule.
|
|
|
|
|
|
|
|
// -----------------------------------
|
|
|
|
// ENUM
|
|
|
|
// -----------------------------------
|
|
|
|
|
2021-08-18 17:21:48 +02:00
|
|
|
{
|
|
|
|
selector: 'enumMember',
|
|
|
|
format: ['StrictPascalCase'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
selector: 'enumMember',
|
|
|
|
format: null,
|
|
|
|
'filter': {
|
2021-10-03 17:00:49 +02:00
|
|
|
'regex': '^(GET|POST|PUT|DELETE|PATCH|HEAD|SQLite|PostgreSQL|ASC|DESC|E2EE|OR|AND|UNION|INTERSECT|EXCLUSION|INCLUSION|EUR|GBP|USD|SJCL.*)$',
|
2021-08-18 17:21:48 +02:00
|
|
|
'match': true,
|
|
|
|
},
|
|
|
|
},
|
2021-10-03 17:00:49 +02:00
|
|
|
|
|
|
|
// -----------------------------------
|
|
|
|
// INTERFACE
|
|
|
|
// -----------------------------------
|
|
|
|
|
2021-08-18 17:21:48 +02:00
|
|
|
{
|
|
|
|
selector: 'interface',
|
|
|
|
format: ['StrictPascalCase'],
|
|
|
|
},
|
2021-10-03 17:00:49 +02:00
|
|
|
{
|
|
|
|
selector: 'interface',
|
|
|
|
format: null,
|
|
|
|
'filter': {
|
|
|
|
'regex': '^(RSA|RSAKeyPair)$',
|
|
|
|
'match': true,
|
|
|
|
},
|
|
|
|
},
|
2021-08-18 17:21:48 +02:00
|
|
|
],
|
2020-10-09 19:35:46 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2020-02-22 13:25:16 +02:00
|
|
|
};
|