MM-52624/MM-57094 Update ESLint and our ESLint plugin (#26398)

* Update ESLint and plugins

* Move most channels-specific ESLint configuration into ESLint plugin

* Add ESLint to types and client packages

* Add ESLint to components package
Этот коммит содержится в:
Harrison Healey
2024-03-13 18:07:28 -04:00
коммит произвёл GitHub
родитель 67f815e373
Коммит 4d03becdd1
53 изменённых файлов: 1149 добавлений и 989 удалений

Просмотреть файл

@@ -1,91 +1,16 @@
{
"root": true,
"extends": [
"plugin:@mattermost/react",
"plugin:react-hooks/recommended"
"plugin:@mattermost/react"
],
"plugins": [
"@mattermost",
"import",
"no-only-tests",
"@typescript-eslint",
"formatjs"
"formatjs",
"no-only-tests"
],
"parser": "@typescript-eslint/parser",
"env": {
"jest": true
},
"settings": {
"import/resolver": "webpack",
"react": {
"pragma": "React",
"version": "detect"
}
"import/resolver": "webpack"
},
"rules": {
"@mattermost/use-external-link": 2,
"header/header": [
2,
"line",
" Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.\n See LICENSE.txt for license information.",
2
],
"no-duplicate-imports": 0,
"import/no-duplicates": 2,
"max-nested-callbacks": ["error", 10],
"no-unused-expressions": 0,
"eol-last": ["error", "always"],
"import/no-unresolved": 2,
"import/order": [
2,
{
"newlines-between": "always",
"groups": [
"builtin",
"external",
"internal",
"sibling",
"parent",
"index"
],
"pathGroups": [
{
"pattern": "@mattermost/**",
"group": "external",
"position": "after"
},
{
"pattern": "mattermost-redux/**",
"group": "external",
"position": "after"
},
{
"pattern": "@(selectors|actions|stores|store|reducers){,/**}",
"group": "external",
"position": "after"
},
{
"pattern": "components/**",
"group": "external",
"position": "after"
},
{
"pattern": "types{,/**}",
"group": "internal",
"position": "after"
}
],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
},
"distinctGroup": true,
"pathGroupsExcludedImportTypes": ["builtin"]
}
],
"no-undefined": 0,
"no-use-before-define": 0,
"react/jsx-filename-extension": 0,
"react/prop-types": [
2,
{
@@ -104,116 +29,16 @@
]
}
],
"react/no-string-refs": 2,
"no-only-tests/no-only-tests": ["error", {"focus": ["only", "skip"]}],
"react/style-prop-object": [2, {
"allow": ["Timestamp"]
}],
"no-restricted-imports": [
"error",
{
"patterns": [
{
"group": ["@mattermost/compass-components/*"],
"message": "compass-components is now archived."
}
],
"paths": [
{
"name": "react-bootstrap",
"importNames": ["OverlayTrigger"],
"message": "Use OverlayTrigger from '/components/overlay_trigger' instead."
},
{
"name": "redux",
"importNames": ["DeepPartial"],
"message": "Use DeepPartial from '@mattermost/types/utilities instead."
},
{
"name": "lodash",
"message": "Import individual functions from lodash/<function> instead."
}
]
}
],
"max-lines": ["warn", {"max": 800, "skipBlankLines": true, "skipComments": true}],
"formatjs/no-multiple-whitespaces": 2,
"@typescript-eslint/consistent-type-imports": ["error", {"disallowTypeAnnotations": false}]
"formatjs/no-multiple-whitespaces": 2
},
"overrides": [
{
"files": ["**/*.tsx", "**/*.ts"],
"extends": [
"plugin:@typescript-eslint/recommended"
],
"files": ["*.test.*", "src/tests/**"],
"rules": {
"camelcase": 0,
"no-shadow": 0,
"import/no-unresolved": 0, // ts handles this better
"@typescript-eslint/naming-convention": [
2,
{
"selector": "function",
"format": ["camelCase", "PascalCase"]
},
{
"selector": "variable",
"format": ["camelCase", "PascalCase", "UPPER_CASE"]
},
{
"selector": "parameter",
"format": ["camelCase", "PascalCase"],
"leadingUnderscore": "allow"
},
{
"selector": "typeLike",
"format": ["PascalCase"]
}
],
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-unused-vars": [
2,
{
"vars": "all",
"args": "after-used"
}
],
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/prefer-interface": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/indent": [
2,
4,
{
"SwitchCase": 0
}
],
"@typescript-eslint/no-use-before-define": [
2,
{
"classes": false,
"functions": false,
"variables": false
}
]
}
},
{
"files": ["src/tests/**", "**/*.test.*", "src/tests/*.js", "src/packages/mattermost-redux/test/*"],
"env": {
"jest": true
},
"rules": {
"func-names": 0,
"global-require": 0,
"max-lines": 0,
"new-cap": 0,
"no-empty-function": 0,
"no-import-assign": 0,
"no-process-env": 0,
"prefer-arrow-callback": 0
"no-only-tests/no-only-tests": ["error", {"focus": ["only", "skip"]}]
}
}
]

Просмотреть файл

@@ -141,8 +141,6 @@
"@types/shallow-equals": "1.0.3",
"@types/styled-components": "5.1.32",
"@types/tinycolor2": "1.4.3",
"@typescript-eslint/eslint-plugin": "5.57.1",
"@typescript-eslint/parser": "5.57.1",
"copy-webpack-plugin": "11.0.0",
"emoji-datasource": "6.1.1",
"emoji-datasource-apple": "6.1.1",
@@ -150,11 +148,7 @@
"enzyme": "3.11.0",
"enzyme-adapter-react-17-updated": "1.0.2",
"enzyme-to-json": "3.6.2",
"eslint-plugin-header": "3.1.1",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"external-remotes-plugin": "1.0.0",
"html-webpack-plugin": "5.5.0",
"identity-obj-proxy": "3.0.0",

Просмотреть файл

@@ -287,7 +287,7 @@ describe('rhs view actions', () => {
jest.resetModules();
const {submitCommand: remockedSubmitCommand} = require('actions/views/create_comment'); // eslint-disable-like @typescript-eslint/no-var-requires
const {submitCommand: remockedSubmitCommand} = require('actions/views/create_comment');
await store.dispatch(remockedSubmitCommand(channelId, rootId, draft));

Просмотреть файл

@@ -283,7 +283,7 @@ describe('handleUserRemovedEvent', () => {
let redirectUserToDefaultTeam;
beforeEach(async () => {
const globalActions = require('actions/global_actions'); // eslint-disable-line global-require
const globalActions = require('actions/global_actions');
redirectUserToDefaultTeam = globalActions.redirectUserToDefaultTeam;
redirectUserToDefaultTeam.mockReset();
});