2020-10-30 20:34:04 +00:00
|
|
|
|
// Copyright 2018-2020 Signal Messenger, LLC
|
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
|
// For reference: https://github.com/airbnb/javascript
|
|
|
|
|
|
2020-09-03 14:59:24 +00:00
|
|
|
|
const rules = {
|
|
|
|
|
'comma-dangle': [
|
|
|
|
|
'error',
|
|
|
|
|
{
|
|
|
|
|
arrays: 'always-multiline',
|
|
|
|
|
objects: 'always-multiline',
|
|
|
|
|
imports: 'always-multiline',
|
|
|
|
|
exports: 'always-multiline',
|
|
|
|
|
functions: 'never',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
|
2020-11-18 15:15:42 +00: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',
|
|
|
|
|
'no-shadow': 'off',
|
|
|
|
|
|
2020-09-03 14:59:24 +00: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',
|
|
|
|
|
|
|
|
|
|
// useful for unused parameters
|
|
|
|
|
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
|
|
|
|
|
|
|
|
// 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',
|
|
|
|
|
'after',
|
|
|
|
|
{ overrides: { '?': 'ignore', ':': 'ignore' } },
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
quotes: [
|
|
|
|
|
'error',
|
|
|
|
|
'single',
|
|
|
|
|
{ avoidEscape: true, allowTemplateLiterals: false },
|
|
|
|
|
],
|
|
|
|
|
|
2020-10-28 01:00:28 +00:00
|
|
|
|
'no-continue': 'off',
|
|
|
|
|
|
2020-09-03 14:59:24 +00:00
|
|
|
|
// Prettier overrides:
|
|
|
|
|
'arrow-parens': 'off',
|
|
|
|
|
'function-paren-newline': 'off',
|
|
|
|
|
'max-len': [
|
|
|
|
|
'error',
|
|
|
|
|
{
|
|
|
|
|
// Prettier generally limits line length to 80 but sometimes goes over.
|
|
|
|
|
// The `max-len` plugin doesn’t let us omit `code` so we set it to a
|
|
|
|
|
// high value as a buffer to let Prettier control the line length:
|
|
|
|
|
code: 999,
|
|
|
|
|
// We still want to limit comments as before:
|
|
|
|
|
comments: 90,
|
|
|
|
|
ignoreUrls: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
|
2020-09-12 00:46:52 +00:00
|
|
|
|
'react/jsx-props-no-spreading': 'off',
|
|
|
|
|
|
|
|
|
|
// Updated to reflect future airbnb standard
|
|
|
|
|
// Allows for declaring defaultProps inside a class
|
|
|
|
|
'react/static-property-placement': ['error', 'static public field'],
|
|
|
|
|
|
|
|
|
|
// JIRA: DESKTOP-657
|
|
|
|
|
'react/sort-comp': 'off',
|
|
|
|
|
|
|
|
|
|
// We don't have control over the media we're sharing, so can't require
|
|
|
|
|
// captions.
|
|
|
|
|
'jsx-a11y/media-has-caption': 'off',
|
|
|
|
|
|
|
|
|
|
// We prefer named exports
|
2020-09-03 14:59:24 +00:00
|
|
|
|
'import/prefer-default-export': 'off',
|
2020-09-12 00:46:52 +00:00
|
|
|
|
|
|
|
|
|
// Prefer functional components with default params
|
|
|
|
|
'react/require-default-props': 'off',
|
2020-09-14 21:56:35 +00:00
|
|
|
|
|
|
|
|
|
'jsx-a11y/label-has-associated-control': ['error', { assert: 'either' }],
|
2020-09-16 14:26:06 +00:00
|
|
|
|
|
|
|
|
|
// Upgrade from a warning
|
|
|
|
|
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
2020-09-03 14:59:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
|
module.exports = {
|
2020-09-01 00:09:28 +00:00
|
|
|
|
root: true,
|
2018-01-08 21:19:25 +00:00
|
|
|
|
settings: {
|
2020-09-01 00:09:28 +00:00
|
|
|
|
react: {
|
|
|
|
|
version: 'detect',
|
|
|
|
|
},
|
2018-04-27 21:25:04 +00:00
|
|
|
|
'import/core-modules': ['electron'],
|
2018-01-08 21:19:25 +00:00
|
|
|
|
},
|
|
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
|
extends: ['airbnb-base', 'prettier'],
|
2018-01-08 21:19:25 +00:00
|
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
|
plugins: ['mocha', 'more'],
|
2018-02-22 18:21:53 +00:00
|
|
|
|
|
2020-09-01 00:09:28 +00:00
|
|
|
|
overrides: [
|
|
|
|
|
{
|
2020-09-14 21:56:35 +00:00
|
|
|
|
files: ['ts/**/*.ts', 'ts/**/*.tsx'],
|
2020-09-01 00:09:28 +00:00
|
|
|
|
parser: '@typescript-eslint/parser',
|
|
|
|
|
parserOptions: {
|
|
|
|
|
project: 'tsconfig.json',
|
|
|
|
|
ecmaFeatures: {
|
|
|
|
|
jsx: true,
|
|
|
|
|
},
|
|
|
|
|
ecmaVersion: 2018,
|
|
|
|
|
sourceType: 'module',
|
|
|
|
|
},
|
|
|
|
|
plugins: ['@typescript-eslint'],
|
|
|
|
|
extends: [
|
|
|
|
|
'eslint:recommended',
|
|
|
|
|
'plugin:@typescript-eslint/recommended',
|
|
|
|
|
'plugin:react/recommended',
|
|
|
|
|
'airbnb-typescript-prettier',
|
|
|
|
|
],
|
2020-09-03 14:59:24 +00:00
|
|
|
|
rules,
|
2020-09-01 00:09:28 +00:00
|
|
|
|
},
|
2020-09-14 21:56:35 +00:00
|
|
|
|
{
|
|
|
|
|
files: ['sticker-creator/**/*.ts', 'sticker-creator/**/*.tsx'],
|
|
|
|
|
parser: '@typescript-eslint/parser',
|
|
|
|
|
parserOptions: {
|
|
|
|
|
project: './sticker-creator/tsconfig.json',
|
|
|
|
|
ecmaFeatures: {
|
|
|
|
|
jsx: true,
|
|
|
|
|
},
|
|
|
|
|
ecmaVersion: 2018,
|
|
|
|
|
sourceType: 'module',
|
|
|
|
|
},
|
|
|
|
|
plugins: ['@typescript-eslint'],
|
|
|
|
|
extends: [
|
|
|
|
|
'eslint:recommended',
|
|
|
|
|
'plugin:@typescript-eslint/recommended',
|
|
|
|
|
'plugin:react/recommended',
|
|
|
|
|
'airbnb-typescript-prettier',
|
|
|
|
|
],
|
|
|
|
|
rules,
|
|
|
|
|
},
|
2020-09-01 00:09:28 +00:00
|
|
|
|
{
|
2020-09-16 19:31:05 +00:00
|
|
|
|
files: ['**/*.stories.tsx', 'ts/build/**', 'ts/test/**'],
|
2020-09-01 00:09:28 +00:00
|
|
|
|
rules: {
|
2020-09-03 14:59:24 +00:00
|
|
|
|
...rules,
|
2020-09-01 00:09:28 +00:00
|
|
|
|
'import/no-extraneous-dependencies': 'off',
|
2020-09-14 19:51:27 +00:00
|
|
|
|
'react/no-array-index-key': 'off',
|
2020-09-01 00:09:28 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
|
2020-09-03 14:59:24 +00:00
|
|
|
|
rules,
|
2018-01-08 21:19:25 +00:00
|
|
|
|
};
|