Skip to content

Commit

Permalink
Update ESLint, migrate configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Dec 7, 2024
1 parent 0577ffd commit 4505339
Show file tree
Hide file tree
Showing 84 changed files with 1,498 additions and 1,420 deletions.
22 changes: 0 additions & 22 deletions .eslintignore

This file was deleted.

230 changes: 0 additions & 230 deletions .eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion e2e/fixtures/data/attachment.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable sort-keys */
const smallImageAttachment = [
{
type: 'image',
Expand Down
128 changes: 128 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';

import reactHooksPlugin from 'eslint-plugin-react-hooks';
import reactPlugin from 'eslint-plugin-react';
import importPlugin from 'eslint-plugin-import';
import jestPlugin from 'eslint-plugin-jest';
import jestDOMPlugin from 'eslint-plugin-jest-dom';

export default tseslint.config(
{
ignores: ['dist', 'src/@types', '*.{js,ts}'],
},
{
name: 'default',
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
reactPlugin.configs.flat.recommended,
],
files: ['src/**/*.{js,ts,jsx,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooksPlugin,
import: importPlugin,
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'array-callback-return': 'error',
'arrow-body-style': 'error',
'comma-dangle': 'off',
'default-case': 'error',
eqeqeq: ['error', 'smart'],
'jsx-quotes': ['error', 'prefer-single'],
'linebreak-style': ['error', 'unix'],
'no-console': 'off',
'no-mixed-spaces-and-tabs': 'warn',
'no-self-compare': 'error',
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{ ignoreRestSiblings: true, caughtErrors: 'none' },
],
'no-use-before-define': 'off',
'no-useless-concat': 'error',
'no-var': 'error',
'object-shorthand': 'warn',
'prefer-const': 'warn',
'react/jsx-sort-props': [
'error',
{
callbacksLast: false,
ignoreCase: true,
noSortAlphabetically: false,
reservedFirst: false,
shorthandFirst: false,
shorthandLast: false,
},
],
'react/prop-types': 'off',
'require-await': 'error',
semi: ['warn', 'always'],
// TODO: find appropriate plugin for this rule
// "sort-destructure-keys/sort-destructure-keys": [
// "error",
// { caseSensitive: false },
// ],
'sort-imports': [
'error',
{
allowSeparatedGroups: true,
ignoreCase: true,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
},
],
'sort-keys': ['error', 'asc', { caseSensitive: false, minKeys: 2, natural: false }],
'valid-typeof': 'error',
'import/prefer-default-export': 'off',
'import/extensions': 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true, // TODO: set to false once React is in the dependencies (not devDependencies)
optionalDependencies: false,
peerDependencies: false,
},
],
'max-classes-per-file': 'off',
camelcase: 'off',
'react-hooks/rules-of-hooks': 'warn',
'react-hooks/exhaustive-deps': 'error',
'no-unused-expressions': 'off',
'@typescript-eslint/no-non-null-assertion': 'error',
// TODO: remove this rule once all files are .mjs (and require is not used)
'@typescript-eslint/no-require-imports': 'off',
'react/react-in-jsx-scope': 'off',
},
},
{
name: 'jest',
files: ['src/**/__tests__/**'],
plugins: { jest: jestPlugin, 'jest-dom': jestDOMPlugin },
languageOptions: {
globals: jestPlugin.environments.globals.globals,
},
rules: {
'jest/expect-expect': 'off',
'jest/no-conditional-expect': 'off',
'jest/prefer-inline-snapshots': 'off',
'jest/lowercase-name': 'off',
'jest/prefer-expect-assertions': 'off',
'jest/no-hooks': 'off',
'jest/no-if': 'off',
'jest-dom/prefer-in-document': 'error',
},
},
);
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 4505339

Please sign in to comment.