2020-10-23 20:44:41 +02:00
|
|
|
// For reference: https://github.com/airbnb/javascript
|
|
|
|
|
|
|
|
module.exports = {
|
2020-11-03 19:55:50 +01:00
|
|
|
root: true,
|
|
|
|
|
|
|
|
parserOptions: {
|
|
|
|
project: './tsconfig.json',
|
2023-11-08 00:20:58 +01:00
|
|
|
ecmaVersion: 2020,
|
2020-11-11 19:37:14 +01:00
|
|
|
sourceType: 'module',
|
2020-11-03 19:55:50 +01:00
|
|
|
},
|
|
|
|
|
2020-10-23 20:44:41 +02:00
|
|
|
settings: {
|
|
|
|
'import/core-modules': ['electron'],
|
|
|
|
},
|
|
|
|
|
2024-01-19 23:10:24 +01:00
|
|
|
plugins: ['header', 'import', 'jsdoc', 'mocha', 'more', '@typescript-eslint'],
|
2020-10-23 20:44:41 +02:00
|
|
|
|
2020-11-11 19:37:14 +01:00
|
|
|
extends: [
|
|
|
|
'eslint:recommended',
|
|
|
|
'plugin:@typescript-eslint/recommended',
|
2023-03-04 03:34:55 +01:00
|
|
|
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
2020-11-11 19:37:14 +01:00
|
|
|
'plugin:import/errors',
|
|
|
|
'plugin:import/warnings',
|
|
|
|
'plugin:import/typescript',
|
|
|
|
],
|
2020-10-23 20:44:41 +02:00
|
|
|
|
|
|
|
rules: {
|
2020-11-03 20:25:30 +01:00
|
|
|
'header/header': [
|
|
|
|
2,
|
|
|
|
'line',
|
|
|
|
[
|
|
|
|
'',
|
|
|
|
{ pattern: ' Copyright \\d{4}(-\\d{4})? Signal Messenger, LLC.' },
|
|
|
|
' SPDX-License-Identifier: AGPL-3.0-only',
|
|
|
|
'',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
2020-11-11 19:37:14 +01:00
|
|
|
'comma-dangle': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
arrays: 'always-multiline',
|
|
|
|
objects: 'always-multiline',
|
|
|
|
imports: 'always-multiline',
|
|
|
|
exports: 'always-multiline',
|
|
|
|
functions: 'never',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2020-10-23 20:44:41 +02:00
|
|
|
// prevents us from accidentally checking in exclusive tests (`.only`):
|
|
|
|
'mocha/no-exclusive-tests': 'error',
|
|
|
|
|
|
|
|
// encourage consistent use of `async` / `await` instead of `then`
|
|
|
|
'more/no-then': 'error',
|
|
|
|
|
|
|
|
// it helps readability to put public API at top,
|
|
|
|
'no-use-before-define': 'off',
|
|
|
|
|
|
|
|
// useful for unused or internal fields
|
|
|
|
'no-underscore-dangle': 'off',
|
|
|
|
|
2020-11-11 19:37:14 +01:00
|
|
|
// useful for unused parameters
|
2021-10-29 21:45:47 +02:00
|
|
|
'@typescript-eslint/no-unused-vars': [
|
|
|
|
'error',
|
|
|
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
|
|
],
|
2020-11-11 19:37:14 +01:00
|
|
|
|
2023-03-04 03:34:55 +01:00
|
|
|
// Overrides recommended by typescript-eslint
|
|
|
|
// https://github.com/typescript-eslint/typescript-eslint/releases/tag/v4.0.0
|
|
|
|
'@typescript-eslint/no-redeclare': 'error',
|
|
|
|
'@typescript-eslint/no-shadow': ['error', { ignoreOnInitialization: true }],
|
|
|
|
'@typescript-eslint/no-useless-constructor': ['error'],
|
|
|
|
'no-shadow': 'off',
|
|
|
|
'no-useless-constructor': 'off',
|
|
|
|
|
2020-10-23 20:44:41 +02:00
|
|
|
// though we have a logger, we still remap console to log to disk
|
|
|
|
'no-console': 'error',
|
|
|
|
|
|
|
|
// consistently place operators at end of line except ternaries
|
|
|
|
'operator-linebreak': 'error',
|
|
|
|
|
|
|
|
quotes: [
|
|
|
|
'error',
|
|
|
|
'single',
|
|
|
|
{ avoidEscape: true, allowTemplateLiterals: false },
|
|
|
|
],
|
|
|
|
|
2020-11-11 19:37:14 +01:00
|
|
|
// We prefer named exports
|
|
|
|
'import/prefer-default-export': 'off',
|
|
|
|
|
2023-03-04 03:34:55 +01:00
|
|
|
'prefer-template': 'error',
|
|
|
|
|
2020-11-03 19:55:50 +01:00
|
|
|
'@typescript-eslint/no-require-imports': 'error',
|
|
|
|
'@typescript-eslint/consistent-type-assertions': 'error',
|
2020-11-11 19:37:14 +01:00
|
|
|
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
2023-03-04 03:34:55 +01:00
|
|
|
|
|
|
|
// Errors are valid in templates, but this rule doesn't know that.
|
|
|
|
'@typescript-eslint/restrict-template-expressions': 'off',
|
2024-01-19 23:10:24 +01:00
|
|
|
|
|
|
|
// JSDoc checking, but no complaints for missing docs yet
|
2024-03-01 18:59:30 +01:00
|
|
|
'jsdoc/check-access': 'error',
|
|
|
|
'jsdoc/check-alignment': 'error',
|
|
|
|
'jsdoc/check-line-alignment': 'error',
|
|
|
|
'jsdoc/check-param-names': ['error', { disableMissingParamChecks: true }],
|
|
|
|
'jsdoc/check-property-names': 'error',
|
|
|
|
'jsdoc/check-syntax': 'error',
|
|
|
|
'jsdoc/check-tag-names': 'error',
|
|
|
|
'jsdoc/check-types': 'error',
|
|
|
|
'jsdoc/check-values': 'error',
|
|
|
|
'jsdoc/empty-tags': 'error',
|
|
|
|
'jsdoc/implements-on-classes': 'error',
|
|
|
|
'jsdoc/multiline-blocks': 'error',
|
|
|
|
'jsdoc/no-bad-blocks': 'error',
|
|
|
|
'jsdoc/no-blank-blocks': 'error',
|
|
|
|
'jsdoc/no-undefined-types': 'error',
|
|
|
|
'jsdoc/valid-types': 'error',
|
2020-10-23 20:44:41 +02:00
|
|
|
},
|
|
|
|
};
|