Eslint dependencies versions updates (#10839)

* Update eslint version to 7.8.1

* Give names to unnamed functions  to fix lint errors

* Update eslint-import-resolver-webpack

* Update eslint-plugin-cypress

* Add eslint-plugin-react-hooks

* Update necessary peer dependencies for eslint-config-airbnb

* Update eslint airbnb config and ts plugins

* Remove "this" from functional component

* Disable all rules that cause new errors

* Fix linting errors in tests

* Add licenses to .eslintrc files

* Add path and zlib to package.json

* Disable incompatible rule in eslint-plugin-cypress

* Remove redundant config for typescript linting

* Mark disabled rules with comments

* Remove path and zlib from deps, disable import rule for webpack files
This commit is contained in:
Kamil Gabryjelski 2020-09-14 08:59:02 +02:00 committed by GitHub
parent 1f31e0eb38
commit 8a774d59ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1622 additions and 520 deletions

View File

@ -17,7 +17,7 @@
* under the License.
*/
module.exports = {
extends: ['airbnb', 'prettier'],
extends: ['airbnb', 'prettier', 'prettier/react'],
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
@ -36,6 +36,12 @@ module.exports = {
'global-require': 0,
},
},
{
files: ['webpack*.js'],
rules: {
'import/no-extraneous-dependencies': 0,
},
},
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
@ -44,24 +50,25 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
'prettier/react',
],
plugins: ['@typescript-eslint/eslint-plugin', 'prettier', 'react'],
rules: {
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/camelcase': [
'error',
{
allow: ['^UNSAFE_'],
properties: 'never',
},
],
'@typescript-eslint/ban-ts-comment': 0, // disabled temporarily
'@typescript-eslint/ban-types': 0, // disabled temporarily
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-non-null-assertion': 0, // disabled temporarily
'@typescript-eslint/no-use-before-define': 1, // disabled temporarily
'@typescript-eslint/no-unused-vars': 0, // disabled temporarily
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-module-boundary-types': 0, // re-enable up for discussion
camelcase: 0,
'class-methods-use-this': 0,
'func-names': 0,
'guard-for-in': 0,
'import/no-cycle': 0, // re-enable up for discussion, might require some major refactors
'import/extensions': [
'error',
{
@ -72,19 +79,26 @@ module.exports = {
],
'import/no-named-as-default': 0,
'import/no-named-as-default-member': 0,
'import/no-useless-path-segments': 0, // disabled temporarily
'import/prefer-default-export': 0,
indent: 0,
'jsx-a11y/anchor-has-content': 0,
'jsx-a11y/href-no-hash': 0,
'jsx-a11y/anchor-is-valid': 0, // disabled temporarily
'jsx-a11y/click-events-have-key-events': 0, // re-enable up for discussion
'jsx-a11y/control-has-associated-label': 0, // disabled temporarily
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
'lines-between-class-members': 0, // disabled temporarily
'new-cap': 0,
'no-bitwise': 0,
'no-confusing-arrow': 0,
'no-continue': 0,
'no-else-return': 0, // disabled temporarily
'no-mixed-operators': 0,
'no-multi-assign': 0,
'no-multi-spaces': 0,
'no-plusplus': 0,
'no-prototype-builtins': 0,
'no-restricted-globals': 0, // disabled temporarily
'no-restricted-properties': 0,
'no-restricted-syntax': 0,
'no-restricted-imports': [
@ -99,18 +113,30 @@ module.exports = {
],
},
],
'no-shadow': 0, // re-enable up for discussion
'no-use-before-define': 0, // disabled temporarily
'padded-blocks': 0,
'prefer-arrow-callback': 0,
'prefer-destructuring': 0, // disabled temporarily
'react/default-props-match-prop-types': 0, // disabled temporarily
'react/destructuring-assignment': 0, // re-enable up for discussion
'react/forbid-prop-types': 0,
'react/jsx-curly-brace-presence': 0, // disabled temporarily
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
'react/jsx-fragments': 1,
'react/jsx-no-bind': 0,
'react/jsx-props-no-spreading': 0, // re-enable up for discussion
'react/no-access-state-in-setstate': 0, // disabled temporarily
'react/no-array-index-key': 0,
'react/no-string-refs': 0,
'react/no-unescaped-entities': 0,
'react/no-unused-prop-types': 0,
'react/require-default-props': 0,
'react/jsx-fragments': 1,
'react/no-unused-state': 0, // disabled temporarily
'react/prop-types': 0,
'react/require-default-props': 0,
'react/sort-comp': 0, // disabled temporarily
'react/state-in-constructor': 0, // disabled temporarily
'react/static-property-placement': 0, // re-enable up for discussion
'prettier/prettier': 'error',
},
settings: {
@ -174,12 +200,20 @@ module.exports = {
'.json': 'always',
},
],
'import/no-cycle': 0, // re-enable up for discussion, might require some major refactors
'import/no-named-as-default': 0,
'import/no-useless-path-segments': 0, // disabled temporarily
'import/prefer-default-export': 0,
indent: 0,
'jsx-a11y/anchor-has-content': 0,
'jsx-a11y/href-no-hash': 0,
'jsx-a11y/anchor-is-valid': 0, // disabled temporarily
'jsx-a11y/click-events-have-key-events': 0, // re-enable up for discussion
'jsx-a11y/control-has-associated-label': 0, // disabled temporarily
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
'lines-between-class-members': 0, // disabled temporarily
'new-cap': 0,
'no-restricted-globals': 0, // disabled temporarily
'no-else-return': 0, // disabled temporarily
'no-bitwise': 0,
'no-confusing-arrow': 0,
'no-continue': 0,
@ -202,19 +236,30 @@ module.exports = {
],
},
],
'no-shadow': 0, // re-enable up for discussion
'padded-blocks': 0,
'prefer-arrow-callback': 0,
'prefer-object-spread': 1,
'prefer-destructuring': 0, // disabled temporarily
'react/default-props-match-prop-types': 0, // disabled temporarily
'react/destructuring-assignment': 0, // re-enable up for discussion
'react/forbid-prop-types': 0,
'react/jsx-curly-brace-presence': 0, // disabled temporarily
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
'react/jsx-fragments': 1,
'react/jsx-no-bind': 0,
'react/jsx-props-no-spreading': 0, // re-enable up for discussion
'react/no-access-state-in-setstate': 0, // disabled temporarily
'react/no-array-index-key': 0,
'react/no-string-refs': 0,
'react/no-unescaped-entities': 0,
'react/no-unused-prop-types': 0,
'react/require-default-props': 0,
'react/jsx-fragments': 1,
'react/no-unused-state': 0, // disabled temporarily
'react/prop-types': 0,
'react/require-default-props': 0,
'react/sort-comp': 0, // disabled temporarily
'react/state-in-constructor': 0, // disabled temporarily
'react/static-property-placement': 0, // disabled temporarily
'prettier/prettier': 'error',
},
settings: {

View File

@ -1,3 +1,21 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
{
"parser": "@typescript-eslint/parser",
"plugins": ["cypress", "@typescript-eslint"],
@ -10,7 +28,8 @@
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/camelcase": 0
"@typescript-eslint/camelcase": 0,
"cypress/no-unnecessary-waiting": 0 // see issue https://github.com/cypress-io/eslint-plugin-cypress/issues/69
},
"settings": {
"import/resolver": {

File diff suppressed because it is too large Load Diff

View File

@ -217,8 +217,8 @@
"@types/rison": "0.0.6",
"@types/sinon": "^9.0.5",
"@types/yargs": "12 - 15",
"@typescript-eslint/eslint-plugin": "^2.20.0",
"@typescript-eslint/parser": "^2.20.0",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.1.0",
"babel-loader": "^8.0.6",
@ -233,17 +233,18 @@
"emotion-ts-plugin": "^0.5.3",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint": "^6.2.2",
"eslint-config-airbnb": "^15.0.1",
"eslint": "^7.8.1",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-webpack": "^0.10.1",
"eslint-plugin-cypress": "^2.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-import-resolver-webpack": "^0.12.2",
"eslint-plugin-cypress": "^2.11.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.17.1",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-no-only-tests": "^2.0.1",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"exports-loader": "^0.7.0",
"fetch-mock": "^7.7.3",
"file-loader": "^6.0.0",

View File

@ -1,3 +1,21 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
{
"plugins": ["jest", "no-only-tests"],
"env": {
@ -7,6 +25,7 @@
"rules": {
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"jest/consistent-test-it": "error",
"no-only-tests/no-only-tests": "error"
"no-only-tests/no-only-tests": "error",
"prefer-promise-reject-errors": 0
}
}

View File

@ -20,7 +20,6 @@
"no-multi-assign": 2,
"no-restricted-properties": 2,
"no-prototype-builtins": 2,
"jsx-a11y/href-no-hash": 2,
"class-methods-use-this": 2,
"import/no-named-as-default": 2,
"import/prefer-default-export": 2,

View File

@ -29,7 +29,7 @@ import HoverMenu from 'src/dashboard/components/menu/HoverMenu';
import ResizableContainer from 'src/dashboard/components/resizable/ResizableContainer';
import { mockStore } from '../../fixtures/mockStore';
import { sliceId } from '../../fixtures/mockSliceEntities';
import { sliceId } from '../../fixtures/mockChartQueries';
import { dashboardLayout as mockLayout } from '../../fixtures/mockDashboardLayout';
import WithDragDropContext from '../../helpers/WithDragDropContext';

View File

@ -37,7 +37,7 @@ import {
import newComponentFactory from 'src/dashboard/util/newComponentFactory';
import { sliceId as chartId } from './mockChartQueries';
import { filterId } from './mockDashboardFilters';
import { filterId } from './mockSliceEntities';
export const sliceId = chartId;

View File

@ -20,7 +20,6 @@
"no-multi-assign": 2,
"no-restricted-properties": 2,
"no-prototype-builtins": 2,
"jsx-a11y/href-no-hash": 2,
"class-methods-use-this": 2,
"import/no-named-as-default": 2,
"import/prefer-default-export": 2,

View File

@ -12,7 +12,7 @@
"no-confusing-arrow": 2,
"jsx-a11y/no-static-element-interactions": 2,
"jsx-a11y/anchor-has-content": 2,
"react/require-default-props": 2,
"react/require-default-props": 0,
"no-plusplus": 2,
"no-mixed-operators": 0,
"no-continue": 2,
@ -20,7 +20,6 @@
"no-multi-assign": 2,
"no-restricted-properties": 2,
"no-prototype-builtins": 2,
"jsx-a11y/href-no-hash": 2,
"class-methods-use-this": 2,
"import/no-named-as-default": 2,
"import/prefer-default-export": 2,

View File

@ -48,7 +48,7 @@ import getLocationHash from '../util/getLocationHash';
import newComponentFactory from '../util/newComponentFactory';
import { TIME_RANGE } from '../../visualizations/FilterBox/FilterBox';
export default function (bootstrapData) {
export default function getInitialState(bootstrapData) {
const { user_id, datasources, common, editMode, urlParams } = bootstrapData;
const dashboard = { ...bootstrapData.dashboard_data };

View File

@ -19,7 +19,7 @@
import { TABS_TYPE } from './componentTypes';
import { DASHBOARD_ROOT_ID } from './constants';
export default function (layout = {}) {
export default function findFirstParentContainerId(layout = {}) {
// DASHBOARD_GRID_TYPE or TABS_TYPE?
let parent = layout[DASHBOARD_ROOT_ID];
if (

View File

@ -24,7 +24,7 @@ import {
DASHBOARD_VERSION_KEY,
} from './constants';
export default function () {
export default function getEmptyLayout() {
return {
[DASHBOARD_VERSION_KEY]: 'v2',
[DASHBOARD_ROOT_ID]: {

View File

@ -76,7 +76,7 @@ const SelectAsyncControl = props => {
dataEndpoint={dataEndpoint}
onChange={onSelectionChange}
onAsyncError={errorMsg =>
this.props.addDangerToast(`${onAsyncErrorMessage}: ${errorMsg}`)
props.addDangerToast(`${onAsyncErrorMessage}: ${errorMsg}`)
}
mutator={mutator}
multi={multi}