2019-01-04 11:28:38 +01:00
|
|
|
module.exports = {
|
|
|
|
root: true,
|
|
|
|
|
2022-12-18 16:51:37 +01:00
|
|
|
extends: [
|
|
|
|
'eslint:recommended',
|
2023-01-30 03:08:37 +01:00
|
|
|
'plugin:react/recommended',
|
2023-01-30 06:18:12 +01:00
|
|
|
'plugin:jsx-a11y/recommended',
|
2023-02-13 15:12:31 +01:00
|
|
|
'plugin:import/recommended',
|
2023-02-16 07:30:56 +01:00
|
|
|
'plugin:promise/recommended',
|
2022-12-18 16:51:37 +01:00
|
|
|
],
|
|
|
|
|
2019-01-04 11:28:38 +01:00
|
|
|
env: {
|
|
|
|
browser: true,
|
|
|
|
node: true,
|
|
|
|
es6: true,
|
|
|
|
jest: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
globals: {
|
|
|
|
ATTACHMENT_HOST: false,
|
|
|
|
},
|
|
|
|
|
2022-06-01 19:22:35 +02:00
|
|
|
parser: '@babel/eslint-parser',
|
2019-01-04 11:28:38 +01:00
|
|
|
|
|
|
|
plugins: [
|
|
|
|
'react',
|
|
|
|
'jsx-a11y',
|
|
|
|
'import',
|
|
|
|
'promise',
|
|
|
|
],
|
|
|
|
|
|
|
|
parserOptions: {
|
|
|
|
sourceType: 'module',
|
|
|
|
ecmaFeatures: {
|
|
|
|
jsx: true,
|
|
|
|
},
|
2022-06-01 19:22:35 +02:00
|
|
|
ecmaVersion: 2021,
|
2023-03-24 03:17:53 +01:00
|
|
|
requireConfigFile: false,
|
|
|
|
babelOptions: {
|
|
|
|
configFile: false,
|
|
|
|
presets: ['@babel/react', '@babel/env'],
|
|
|
|
},
|
2019-01-04 11:28:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
settings: {
|
|
|
|
react: {
|
|
|
|
version: 'detect',
|
|
|
|
},
|
|
|
|
'import/extensions': [
|
2023-02-20 03:20:59 +01:00
|
|
|
'.js', '.jsx',
|
2019-01-04 11:28:38 +01:00
|
|
|
],
|
|
|
|
'import/ignore': [
|
|
|
|
'node_modules',
|
|
|
|
'\\.(css|scss|json)$',
|
|
|
|
],
|
2019-02-01 00:14:05 +01:00
|
|
|
'import/resolver': {
|
|
|
|
node: {
|
|
|
|
paths: ['app/javascript'],
|
2023-02-20 03:20:59 +01:00
|
|
|
extensions: ['.js', '.jsx'],
|
2019-02-01 00:14:05 +01:00
|
|
|
},
|
|
|
|
},
|
2019-01-04 11:28:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
rules: {
|
|
|
|
'brace-style': 'warn',
|
|
|
|
'comma-dangle': ['error', 'always-multiline'],
|
|
|
|
'comma-spacing': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
before: false,
|
|
|
|
after: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'comma-style': ['warn', 'last'],
|
|
|
|
'consistent-return': 'error',
|
|
|
|
'dot-notation': 'error',
|
|
|
|
eqeqeq: 'error',
|
|
|
|
indent: ['warn', 2],
|
|
|
|
'jsx-quotes': ['error', 'prefer-single'],
|
2022-12-18 16:51:37 +01:00
|
|
|
'no-case-declarations': 'off',
|
2019-01-04 11:28:38 +01:00
|
|
|
'no-catch-shadow': 'error',
|
|
|
|
'no-console': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
allow: [
|
|
|
|
'error',
|
|
|
|
'warn',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-12-18 16:51:37 +01:00
|
|
|
'no-empty': 'off',
|
2022-04-04 18:19:45 +02:00
|
|
|
'no-restricted-properties': [
|
|
|
|
'error',
|
|
|
|
{ property: 'substring', message: 'Use .slice instead of .substring.' },
|
|
|
|
{ property: 'substr', message: 'Use .slice instead of .substr.' },
|
|
|
|
],
|
2022-12-18 16:51:37 +01:00
|
|
|
'no-self-assign': 'off',
|
2019-01-04 11:28:38 +01:00
|
|
|
'no-trailing-spaces': 'warn',
|
|
|
|
'no-unused-expressions': 'error',
|
|
|
|
'no-unused-vars': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
vars: 'all',
|
|
|
|
args: 'after-used',
|
|
|
|
ignoreRestSiblings: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'object-curly-spacing': ['error', 'always'],
|
|
|
|
'padded-blocks': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
classes: 'always',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
quotes: ['error', 'single'],
|
|
|
|
semi: 'error',
|
|
|
|
'valid-typeof': 'error',
|
|
|
|
|
2023-02-20 03:20:59 +01:00
|
|
|
'react/jsx-filename-extension': ['error', { 'allow': 'as-needed' }],
|
2019-01-04 11:28:38 +01:00
|
|
|
'react/jsx-boolean-value': 'error',
|
|
|
|
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
|
|
|
|
'react/jsx-curly-spacing': 'error',
|
2023-01-30 03:08:37 +01:00
|
|
|
'react/display-name': 'off',
|
2019-01-04 11:28:38 +01:00
|
|
|
'react/jsx-equals-spacing': 'error',
|
|
|
|
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
|
|
|
|
'react/jsx-indent': ['error', 2],
|
|
|
|
'react/jsx-no-bind': 'error',
|
2023-01-30 03:08:37 +01:00
|
|
|
'react/jsx-no-target-blank': 'off',
|
2019-01-04 11:28:38 +01:00
|
|
|
'react/jsx-tag-spacing': 'error',
|
|
|
|
'react/jsx-wrap-multilines': 'error',
|
2023-01-30 03:08:37 +01:00
|
|
|
'react/no-deprecated': 'off',
|
|
|
|
'react/no-unknown-property': 'off',
|
2019-01-04 11:28:38 +01:00
|
|
|
'react/self-closing-comp': 'error',
|
|
|
|
|
2023-01-30 06:18:12 +01:00
|
|
|
// recommended values found in https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js
|
2019-01-04 11:28:38 +01:00
|
|
|
'jsx-a11y/accessible-emoji': 'warn',
|
2023-01-30 06:18:12 +01:00
|
|
|
'jsx-a11y/click-events-have-key-events': 'off',
|
|
|
|
'jsx-a11y/label-has-associated-control': 'off',
|
|
|
|
'jsx-a11y/media-has-caption': 'off',
|
|
|
|
'jsx-a11y/no-autofocus': 'off',
|
|
|
|
// recommended rule is:
|
|
|
|
// 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
|
|
|
|
// 'error',
|
|
|
|
// {
|
|
|
|
// tr: ['none', 'presentation'],
|
|
|
|
// canvas: ['img'],
|
|
|
|
// },
|
|
|
|
// ],
|
|
|
|
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'off',
|
|
|
|
// recommended rule is:
|
|
|
|
// 'jsx-a11y/no-noninteractive-element-interactions': [
|
|
|
|
// 'error',
|
|
|
|
// {
|
|
|
|
// body: ['onError', 'onLoad'],
|
|
|
|
// iframe: ['onError', 'onLoad'],
|
|
|
|
// img: ['onError', 'onLoad'],
|
|
|
|
// },
|
|
|
|
// ],
|
2019-01-04 11:28:38 +01:00
|
|
|
'jsx-a11y/no-noninteractive-element-interactions': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
handlers: [
|
|
|
|
'onClick',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-01-30 06:18:12 +01:00
|
|
|
// recommended rule is:
|
|
|
|
// 'jsx-a11y/no-noninteractive-tabindex': [
|
|
|
|
// 'error',
|
|
|
|
// {
|
|
|
|
// tags: [],
|
|
|
|
// roles: ['tabpanel'],
|
|
|
|
// allowExpressionValues: true,
|
|
|
|
// },
|
|
|
|
// ],
|
|
|
|
'jsx-a11y/no-noninteractive-tabindex': 'off',
|
2019-01-04 11:28:38 +01:00
|
|
|
'jsx-a11y/no-onchange': 'warn',
|
2023-01-30 06:18:12 +01:00
|
|
|
// recommended is full 'error'
|
2019-01-04 11:28:38 +01:00
|
|
|
'jsx-a11y/no-static-element-interactions': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
handlers: [
|
|
|
|
'onClick',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2023-02-13 15:12:31 +01:00
|
|
|
// See https://github.com/import-js/eslint-plugin-import/blob/main/config/recommended.js
|
2019-01-04 11:28:38 +01:00
|
|
|
'import/extensions': [
|
|
|
|
'error',
|
|
|
|
'always',
|
|
|
|
{
|
|
|
|
js: 'never',
|
2023-02-20 03:20:59 +01:00
|
|
|
jsx: 'never',
|
2019-01-04 11:28:38 +01:00
|
|
|
},
|
|
|
|
],
|
|
|
|
'import/newline-after-import': 'error',
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
devDependencies: [
|
|
|
|
'config/webpack/**',
|
|
|
|
'app/javascript/mastodon/test_setup.js',
|
|
|
|
'app/javascript/**/__tests__/**',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'import/no-webpack-loader-syntax': 'error',
|
|
|
|
|
2023-02-16 07:30:56 +01:00
|
|
|
'promise/always-return': 'off',
|
2020-07-11 23:51:22 +02:00
|
|
|
'promise/catch-or-return': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
allowFinally: true,
|
|
|
|
},
|
|
|
|
],
|
2023-02-16 07:30:56 +01:00
|
|
|
'promise/no-callback-in-promise': 'off',
|
|
|
|
'promise/no-nesting': 'off',
|
|
|
|
'promise/no-promise-in-callback': 'off',
|
2019-01-04 11:28:38 +01:00
|
|
|
},
|
2023-03-24 03:17:53 +01:00
|
|
|
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'*.config.js',
|
|
|
|
'.*rc.js',
|
|
|
|
'ide-helper.js',
|
|
|
|
],
|
|
|
|
|
|
|
|
env: {
|
|
|
|
commonjs: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
parserOptions: {
|
|
|
|
sourceType: 'script',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2019-01-04 11:28:38 +01:00
|
|
|
};
|