2019-01-04 19:28:38 +09:00
|
|
|
module.exports = {
|
|
|
|
root: true,
|
|
|
|
|
2022-12-19 00:51:37 +09:00
|
|
|
extends: [
|
|
|
|
'eslint:recommended',
|
2023-01-30 11:08:37 +09:00
|
|
|
'plugin:react/recommended',
|
2023-05-09 10:09:11 +09:00
|
|
|
'plugin:react-hooks/recommended',
|
2023-01-30 14:18:12 +09:00
|
|
|
'plugin:jsx-a11y/recommended',
|
2023-02-13 23:12:31 +09:00
|
|
|
'plugin:import/recommended',
|
2023-02-16 15:30:56 +09:00
|
|
|
'plugin:promise/recommended',
|
2023-04-30 09:29:54 +09:00
|
|
|
'plugin:jsdoc/recommended',
|
2023-05-10 02:02:12 +09:00
|
|
|
'plugin:prettier/recommended',
|
2022-12-19 00:51:37 +09:00
|
|
|
],
|
|
|
|
|
2019-01-04 19:28:38 +09:00
|
|
|
env: {
|
|
|
|
browser: true,
|
|
|
|
node: true,
|
|
|
|
es6: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
globals: {
|
|
|
|
ATTACHMENT_HOST: false,
|
|
|
|
},
|
|
|
|
|
2023-04-03 10:31:39 +09:00
|
|
|
parser: '@typescript-eslint/parser',
|
2019-01-04 19:28:38 +09:00
|
|
|
|
|
|
|
plugins: [
|
|
|
|
'react',
|
|
|
|
'jsx-a11y',
|
|
|
|
'import',
|
|
|
|
'promise',
|
2023-04-03 10:31:39 +09:00
|
|
|
'@typescript-eslint',
|
2023-04-24 05:46:13 +09:00
|
|
|
'formatjs',
|
2019-01-04 19:28:38 +09:00
|
|
|
],
|
|
|
|
|
|
|
|
parserOptions: {
|
|
|
|
sourceType: 'module',
|
|
|
|
ecmaFeatures: {
|
|
|
|
jsx: true,
|
|
|
|
},
|
2022-06-02 02:22:35 +09:00
|
|
|
ecmaVersion: 2021,
|
2023-03-24 11:17:53 +09:00
|
|
|
requireConfigFile: false,
|
|
|
|
babelOptions: {
|
|
|
|
configFile: false,
|
|
|
|
presets: ['@babel/react', '@babel/env'],
|
|
|
|
},
|
2019-01-04 19:28:38 +09:00
|
|
|
},
|
2023-04-03 19:41:10 +09:00
|
|
|
|
2019-01-04 19:28:38 +09:00
|
|
|
settings: {
|
|
|
|
react: {
|
|
|
|
version: 'detect',
|
|
|
|
},
|
|
|
|
'import/ignore': [
|
|
|
|
'node_modules',
|
|
|
|
'\\.(css|scss|json)$',
|
|
|
|
],
|
2019-02-01 08:14:05 +09:00
|
|
|
'import/resolver': {
|
|
|
|
node: {
|
|
|
|
paths: ['app/javascript'],
|
2023-04-03 10:31:39 +09:00
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
2019-02-01 08:14:05 +09:00
|
|
|
},
|
|
|
|
},
|
2019-01-04 19:28:38 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
rules: {
|
|
|
|
'consistent-return': 'error',
|
|
|
|
'dot-notation': 'error',
|
2023-04-20 00:46:46 +09:00
|
|
|
eqeqeq: ['error', 'always', { 'null': 'ignore' }],
|
2019-01-04 19:28:38 +09:00
|
|
|
'jsx-quotes': ['error', 'prefer-single'],
|
2022-12-19 00:51:37 +09:00
|
|
|
'no-case-declarations': 'off',
|
2019-01-04 19:28:38 +09:00
|
|
|
'no-catch-shadow': 'error',
|
|
|
|
'no-console': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
allow: [
|
|
|
|
'error',
|
|
|
|
'warn',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2022-12-19 00:51:37 +09:00
|
|
|
'no-empty': 'off',
|
2022-04-05 01:19:45 +09:00
|
|
|
'no-restricted-properties': [
|
|
|
|
'error',
|
|
|
|
{ property: 'substring', message: 'Use .slice instead of .substring.' },
|
|
|
|
{ property: 'substr', message: 'Use .slice instead of .substr.' },
|
|
|
|
],
|
2022-12-19 00:51:37 +09:00
|
|
|
'no-self-assign': 'off',
|
2019-01-04 19:28:38 +09:00
|
|
|
'no-unused-expressions': 'error',
|
2023-04-03 10:31:39 +09:00
|
|
|
'no-unused-vars': 'off',
|
|
|
|
'@typescript-eslint/no-unused-vars': [
|
2019-01-04 19:28:38 +09:00
|
|
|
'error',
|
|
|
|
{
|
|
|
|
vars: 'all',
|
|
|
|
args: 'after-used',
|
2023-05-09 10:08:47 +09:00
|
|
|
destructuredArrayIgnorePattern: '^_',
|
2019-01-04 19:28:38 +09:00
|
|
|
ignoreRestSiblings: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'valid-typeof': 'error',
|
|
|
|
|
2023-04-03 10:31:39 +09:00
|
|
|
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', 'tsx'] }],
|
2019-01-04 19:28:38 +09:00
|
|
|
'react/jsx-boolean-value': 'error',
|
2023-01-30 11:08:37 +09:00
|
|
|
'react/display-name': 'off',
|
2019-01-04 19:28:38 +09:00
|
|
|
'react/jsx-equals-spacing': 'error',
|
|
|
|
'react/jsx-no-bind': 'error',
|
2023-01-30 11:08:37 +09:00
|
|
|
'react/jsx-no-target-blank': 'off',
|
|
|
|
'react/no-deprecated': 'off',
|
|
|
|
'react/no-unknown-property': 'off',
|
2019-01-04 19:28:38 +09:00
|
|
|
'react/self-closing-comp': 'error',
|
|
|
|
|
2023-01-30 14:18:12 +09:00
|
|
|
// recommended values found in https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js
|
2019-01-04 19:28:38 +09:00
|
|
|
'jsx-a11y/accessible-emoji': 'warn',
|
2023-01-30 14:18:12 +09: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 19:28:38 +09:00
|
|
|
'jsx-a11y/no-noninteractive-element-interactions': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
handlers: [
|
|
|
|
'onClick',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-01-30 14:18:12 +09:00
|
|
|
// recommended rule is:
|
|
|
|
// 'jsx-a11y/no-noninteractive-tabindex': [
|
|
|
|
// 'error',
|
|
|
|
// {
|
|
|
|
// tags: [],
|
|
|
|
// roles: ['tabpanel'],
|
|
|
|
// allowExpressionValues: true,
|
|
|
|
// },
|
|
|
|
// ],
|
|
|
|
'jsx-a11y/no-noninteractive-tabindex': 'off',
|
2019-01-04 19:28:38 +09:00
|
|
|
'jsx-a11y/no-onchange': 'warn',
|
2023-01-30 14:18:12 +09:00
|
|
|
// recommended is full 'error'
|
2019-01-04 19:28:38 +09:00
|
|
|
'jsx-a11y/no-static-element-interactions': [
|
|
|
|
'warn',
|
|
|
|
{
|
|
|
|
handlers: [
|
|
|
|
'onClick',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
2023-02-13 23:12:31 +09:00
|
|
|
// See https://github.com/import-js/eslint-plugin-import/blob/main/config/recommended.js
|
2019-01-04 19:28:38 +09:00
|
|
|
'import/extensions': [
|
|
|
|
'error',
|
|
|
|
'always',
|
|
|
|
{
|
|
|
|
js: 'never',
|
2023-02-20 11:20:59 +09:00
|
|
|
jsx: 'never',
|
2023-04-03 10:31:39 +09:00
|
|
|
ts: 'never',
|
|
|
|
tsx: 'never',
|
2019-01-04 19:28:38 +09:00
|
|
|
},
|
|
|
|
],
|
|
|
|
'import/newline-after-import': 'error',
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
devDependencies: [
|
|
|
|
'config/webpack/**',
|
2023-04-03 19:41:10 +09:00
|
|
|
'app/javascript/mastodon/performance.js',
|
2019-01-04 19:28:38 +09:00
|
|
|
'app/javascript/mastodon/test_setup.js',
|
|
|
|
'app/javascript/**/__tests__/**',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-05-09 10:08:47 +09:00
|
|
|
'import/no-amd': 'error',
|
|
|
|
'import/no-commonjs': 'error',
|
|
|
|
'import/no-import-module-exports': 'error',
|
2019-01-04 19:28:38 +09:00
|
|
|
'import/no-webpack-loader-syntax': 'error',
|
|
|
|
|
2023-02-16 15:30:56 +09:00
|
|
|
'promise/always-return': 'off',
|
2020-07-12 06:51:22 +09:00
|
|
|
'promise/catch-or-return': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
allowFinally: true,
|
|
|
|
},
|
|
|
|
],
|
2023-02-16 15:30:56 +09:00
|
|
|
'promise/no-callback-in-promise': 'off',
|
|
|
|
'promise/no-nesting': 'off',
|
|
|
|
'promise/no-promise-in-callback': 'off',
|
2023-04-24 05:46:13 +09:00
|
|
|
|
|
|
|
'formatjs/blocklist-elements': 'error',
|
|
|
|
'formatjs/enforce-default-message': ['error', 'literal'],
|
|
|
|
'formatjs/enforce-description': 'off', // description values not currently used
|
|
|
|
'formatjs/enforce-id': 'off', // Explicit IDs are used in the project
|
|
|
|
'formatjs/enforce-placeholders': 'off', // Issues in short_number.jsx
|
|
|
|
'formatjs/enforce-plural-rules': 'error',
|
|
|
|
'formatjs/no-camel-case': 'off', // disabledAccount is only non-conforming
|
|
|
|
'formatjs/no-complex-selectors': 'error',
|
|
|
|
'formatjs/no-emoji': 'error',
|
|
|
|
'formatjs/no-id': 'off', // IDs are used for translation keys
|
|
|
|
'formatjs/no-invalid-icu': 'error',
|
|
|
|
'formatjs/no-literal-string-in-jsx': 'off', // Should be looked at, but mainly flagging punctuation outside of strings
|
|
|
|
'formatjs/no-multiple-plurals': 'off', // Only used by hashtag.jsx
|
|
|
|
'formatjs/no-multiple-whitespaces': 'error',
|
|
|
|
'formatjs/no-offset': 'error',
|
|
|
|
'formatjs/no-useless-message': 'error',
|
|
|
|
'formatjs/prefer-formatted-message': 'error',
|
2023-04-24 15:07:19 +09:00
|
|
|
'formatjs/prefer-pound-in-plural': 'error',
|
2023-04-30 09:29:54 +09:00
|
|
|
|
|
|
|
'jsdoc/check-types': 'off',
|
|
|
|
'jsdoc/no-undefined-types': 'off',
|
|
|
|
'jsdoc/require-jsdoc': 'off',
|
|
|
|
'jsdoc/require-param-description': 'off',
|
|
|
|
'jsdoc/require-property-description': 'off',
|
|
|
|
'jsdoc/require-returns-description': 'off',
|
|
|
|
'jsdoc/require-returns': 'off',
|
2019-01-04 19:28:38 +09:00
|
|
|
},
|
2023-03-24 11:17:53 +09:00
|
|
|
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'*.config.js',
|
|
|
|
'.*rc.js',
|
|
|
|
'ide-helper.js',
|
2023-05-09 10:08:47 +09:00
|
|
|
'config/webpack/**/*',
|
2023-03-24 11:17:53 +09:00
|
|
|
],
|
|
|
|
|
|
|
|
env: {
|
|
|
|
commonjs: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
parserOptions: {
|
|
|
|
sourceType: 'script',
|
|
|
|
},
|
2023-05-09 10:08:47 +09:00
|
|
|
|
|
|
|
rules: {
|
|
|
|
'import/no-commonjs': 'off',
|
|
|
|
},
|
2023-03-24 11:17:53 +09:00
|
|
|
},
|
2023-04-03 19:41:10 +09:00
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'**/*.ts',
|
|
|
|
'**/*.tsx',
|
|
|
|
],
|
|
|
|
|
|
|
|
extends: [
|
|
|
|
'eslint:recommended',
|
|
|
|
'plugin:@typescript-eslint/recommended',
|
|
|
|
'plugin:react/recommended',
|
2023-05-09 10:09:11 +09:00
|
|
|
'plugin:react-hooks/recommended',
|
2023-04-03 19:41:10 +09:00
|
|
|
'plugin:jsx-a11y/recommended',
|
|
|
|
'plugin:import/recommended',
|
|
|
|
'plugin:import/typescript',
|
|
|
|
'plugin:promise/recommended',
|
2023-04-30 09:29:54 +09:00
|
|
|
'plugin:jsdoc/recommended',
|
2023-05-10 02:02:12 +09:00
|
|
|
'plugin:prettier/recommended',
|
2023-04-03 19:41:10 +09:00
|
|
|
],
|
|
|
|
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
2023-04-30 09:29:54 +09:00
|
|
|
|
|
|
|
'jsdoc/require-jsdoc': 'off',
|
2023-05-09 10:11:56 +09:00
|
|
|
|
|
|
|
// Those rules set stricter rules for TS files
|
|
|
|
// to enforce better practices when converting from JS
|
|
|
|
'import/no-default-export': 'warn',
|
|
|
|
'react/prefer-stateless-function': 'warn',
|
|
|
|
'react/function-component-definition': ['error', { namedComponents: 'arrow-function' }],
|
2023-04-03 19:41:10 +09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'**/__tests__/*.js',
|
|
|
|
'**/__tests__/*.jsx',
|
|
|
|
],
|
|
|
|
|
|
|
|
env: {
|
|
|
|
jest: true,
|
|
|
|
},
|
|
|
|
},
|
2023-05-09 10:08:47 +09:00
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'streaming/**/*',
|
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'import/no-commonjs': 'off',
|
|
|
|
},
|
|
|
|
},
|
2023-03-24 11:17:53 +09:00
|
|
|
],
|
2019-01-04 19:28:38 +09:00
|
|
|
};
|