2020-02-20 12:54:33 -05:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2021-11-17 02:31:36 -05:00
|
|
|
const packageConfig = require('./package');
|
|
|
|
|
|
|
|
const importCoreModules = [];
|
|
|
|
Object.entries(packageConfig.dependencies).forEach(([pkg]) => {
|
|
|
|
if (/@superset-ui/.test(pkg)) {
|
|
|
|
importCoreModules.push(pkg);
|
|
|
|
}
|
|
|
|
});
|
2021-11-29 19:29:57 -05:00
|
|
|
|
2022-01-05 06:31:12 -05:00
|
|
|
// ignore files in production mode
|
2021-11-29 19:29:57 -05:00
|
|
|
let ignorePatterns = [];
|
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
ignorePatterns = [
|
|
|
|
'*.test.{js,ts,jsx,tsx}',
|
|
|
|
'plugins/**/test/**/*',
|
|
|
|
'packages/**/test/**/*',
|
|
|
|
'packages/generator-superset/**/*',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-02-20 12:54:33 -05:00
|
|
|
module.exports = {
|
2020-09-22 18:09:22 -04:00
|
|
|
extends: [
|
|
|
|
'airbnb',
|
|
|
|
'prettier',
|
|
|
|
'prettier/react',
|
|
|
|
'plugin:react-hooks/recommended',
|
|
|
|
],
|
2021-10-05 18:02:57 -04:00
|
|
|
parser: '@babel/eslint-parser',
|
2020-02-20 12:54:33 -05:00
|
|
|
parserOptions: {
|
|
|
|
ecmaFeatures: {
|
|
|
|
experimentalObjectRestSpread: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
env: {
|
|
|
|
browser: true,
|
2022-01-05 06:31:12 -05:00
|
|
|
node: true,
|
2020-02-20 12:54:33 -05:00
|
|
|
},
|
2020-09-16 12:26:14 -04:00
|
|
|
settings: {
|
2021-11-17 02:31:36 -05:00
|
|
|
'import/resolver': {
|
|
|
|
node: {
|
|
|
|
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
|
2022-01-05 06:31:12 -05:00
|
|
|
// resolve modules from `/superset_frontend/node_modules` and `/superset_frontend`
|
|
|
|
moduleDirectory: ['node_modules', '.'],
|
2021-11-17 02:31:36 -05:00
|
|
|
},
|
|
|
|
},
|
2022-01-07 20:16:24 -05:00
|
|
|
// only allow import from top level of module
|
2021-11-17 02:31:36 -05:00
|
|
|
'import/core-modules': importCoreModules,
|
2020-09-16 12:26:14 -04:00
|
|
|
react: {
|
|
|
|
version: 'detect',
|
|
|
|
},
|
|
|
|
},
|
2022-04-27 05:44:13 -04:00
|
|
|
plugins: [
|
|
|
|
'prettier',
|
|
|
|
'react',
|
|
|
|
'file-progress',
|
|
|
|
'theme-colors',
|
|
|
|
'translation-vars',
|
|
|
|
],
|
2020-02-20 12:54:33 -05:00
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
files: ['*.ts', '*.tsx'],
|
|
|
|
parser: '@typescript-eslint/parser',
|
|
|
|
extends: [
|
|
|
|
'airbnb',
|
|
|
|
'plugin:@typescript-eslint/recommended',
|
|
|
|
'prettier',
|
|
|
|
'prettier/@typescript-eslint',
|
2020-09-14 02:59:02 -04:00
|
|
|
'prettier/react',
|
2020-02-20 12:54:33 -05:00
|
|
|
],
|
2020-03-17 18:37:07 -04:00
|
|
|
plugins: ['@typescript-eslint/eslint-plugin', 'prettier', 'react'],
|
2020-02-20 12:54:33 -05:00
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/ban-ts-ignore': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'@typescript-eslint/ban-ts-comment': 0, // disabled temporarily
|
|
|
|
'@typescript-eslint/ban-types': 0, // disabled temporarily
|
2020-03-13 18:14:50 -04:00
|
|
|
'@typescript-eslint/no-empty-function': 0,
|
2020-02-20 12:54:33 -05:00
|
|
|
'@typescript-eslint/no-explicit-any': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'@typescript-eslint/no-use-before-define': 1, // disabled temporarily
|
2021-11-17 02:31:36 -05:00
|
|
|
'@typescript-eslint/no-non-null-assertion': 0, // disabled temporarily
|
2020-02-20 12:54:33 -05:00
|
|
|
'@typescript-eslint/explicit-function-return-type': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'@typescript-eslint/explicit-module-boundary-types': 0, // re-enable up for discussion
|
2022-10-03 11:17:20 -04:00
|
|
|
'@typescript-eslint/prefer-optional-chain': 2,
|
2020-02-20 12:54:33 -05:00
|
|
|
camelcase: 0,
|
|
|
|
'class-methods-use-this': 0,
|
|
|
|
'func-names': 0,
|
|
|
|
'guard-for-in': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'import/no-cycle': 0, // re-enable up for discussion, might require some major refactors
|
2020-02-20 12:54:33 -05:00
|
|
|
'import/extensions': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
'.ts': 'always',
|
|
|
|
'.tsx': 'always',
|
|
|
|
'.json': 'always',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'import/no-named-as-default-member': 0,
|
|
|
|
'import/prefer-default-export': 0,
|
|
|
|
indent: 0,
|
2020-12-02 13:14:56 -05:00
|
|
|
'jsx-a11y/anchor-is-valid': 1,
|
2020-09-14 02:59:02 -04:00
|
|
|
'jsx-a11y/click-events-have-key-events': 0, // re-enable up for discussion
|
|
|
|
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
|
2022-08-17 13:39:44 -04:00
|
|
|
'max-classes-per-file': 0,
|
2020-02-20 12:54:33 -05:00
|
|
|
'new-cap': 0,
|
|
|
|
'no-bitwise': 0,
|
|
|
|
'no-continue': 0,
|
|
|
|
'no-mixed-operators': 0,
|
|
|
|
'no-multi-assign': 0,
|
|
|
|
'no-multi-spaces': 0,
|
2021-02-28 13:10:15 -05:00
|
|
|
'no-nested-ternary': 0,
|
2020-02-20 12:54:33 -05:00
|
|
|
'no-prototype-builtins': 0,
|
|
|
|
'no-restricted-properties': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'no-shadow': 0, // re-enable up for discussion
|
|
|
|
'no-use-before-define': 0, // disabled temporarily
|
2020-02-20 12:54:33 -05:00
|
|
|
'padded-blocks': 0,
|
|
|
|
'prefer-arrow-callback': 0,
|
2020-09-14 13:11:20 -04:00
|
|
|
'prefer-destructuring': ['error', { object: true, array: false }],
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/destructuring-assignment': 0, // re-enable up for discussion
|
2020-02-20 12:54:33 -05:00
|
|
|
'react/forbid-prop-types': 0,
|
|
|
|
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/jsx-fragments': 1,
|
2020-02-20 12:54:33 -05:00
|
|
|
'react/jsx-no-bind': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/jsx-props-no-spreading': 0, // re-enable up for discussion
|
2020-02-20 12:54:33 -05:00
|
|
|
'react/no-array-index-key': 0,
|
|
|
|
'react/no-string-refs': 0,
|
|
|
|
'react/no-unescaped-entities': 0,
|
|
|
|
'react/no-unused-prop-types': 0,
|
|
|
|
'react/prop-types': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/require-default-props': 0,
|
2021-01-10 20:26:35 -05:00
|
|
|
'react/sort-comp': 0, // TODO: re-enable in separate PR
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/static-property-placement': 0, // re-enable up for discussion
|
2020-02-20 12:54:33 -05:00
|
|
|
'prettier/prettier': 'error',
|
2021-11-08 10:48:51 -05:00
|
|
|
'file-progress/activate': 1,
|
2020-02-20 12:54:33 -05:00
|
|
|
},
|
|
|
|
settings: {
|
2020-09-15 18:33:49 -04:00
|
|
|
'import/resolver': {
|
|
|
|
typescript: {},
|
|
|
|
},
|
2020-02-20 12:54:33 -05:00
|
|
|
react: {
|
|
|
|
version: 'detect',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-08-21 13:32:37 -04:00
|
|
|
{
|
|
|
|
files: [
|
2021-11-17 02:31:36 -05:00
|
|
|
'*.test.ts',
|
|
|
|
'*.test.tsx',
|
|
|
|
'*.test.js',
|
|
|
|
'*.test.jsx',
|
2022-01-07 20:16:24 -05:00
|
|
|
'*.stories.tsx',
|
|
|
|
'*.stories.jsx',
|
2021-11-17 02:31:36 -05:00
|
|
|
'fixtures.*',
|
2020-08-21 13:32:37 -04:00
|
|
|
],
|
2022-01-11 01:22:56 -05:00
|
|
|
excludedFiles: 'cypress-base/cypress/**/*',
|
2021-02-11 18:32:22 -05:00
|
|
|
plugins: ['jest', 'jest-dom', 'no-only-tests', 'testing-library'],
|
2020-08-21 13:32:37 -04:00
|
|
|
env: {
|
|
|
|
'jest/globals': true,
|
|
|
|
},
|
2021-02-11 18:32:22 -05:00
|
|
|
settings: {
|
|
|
|
jest: {
|
|
|
|
version: 'detect',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
extends: [
|
|
|
|
'plugin:jest/recommended',
|
|
|
|
'plugin:jest-dom/recommended',
|
|
|
|
'plugin:testing-library/react',
|
|
|
|
],
|
2020-08-21 13:32:37 -04:00
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': [
|
|
|
|
'error',
|
|
|
|
{ devDependencies: true },
|
|
|
|
],
|
|
|
|
'no-only-tests/no-only-tests': 'error',
|
2021-11-17 02:31:36 -05:00
|
|
|
'max-classes-per-file': 0,
|
2022-03-28 09:11:34 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: [
|
|
|
|
'*.test.ts',
|
|
|
|
'*.test.tsx',
|
|
|
|
'*.test.js',
|
|
|
|
'*.test.jsx',
|
|
|
|
'*.stories.tsx',
|
|
|
|
'*.stories.jsx',
|
|
|
|
'fixtures.*',
|
|
|
|
'cypress-base/cypress/**/*',
|
|
|
|
'Stories.tsx',
|
2022-03-30 10:57:21 -04:00
|
|
|
'packages/superset-ui-core/src/style/index.tsx',
|
2022-03-28 09:11:34 -04:00
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'theme-colors/no-literal-colors': 0,
|
2022-04-27 05:44:13 -04:00
|
|
|
'translation-vars/no-template-vars': 0,
|
2022-03-29 09:15:07 -04:00
|
|
|
'no-restricted-imports': 0,
|
2021-11-17 02:31:36 -05:00
|
|
|
},
|
|
|
|
},
|
2020-02-20 12:54:33 -05:00
|
|
|
],
|
|
|
|
rules: {
|
2022-05-12 14:07:56 -04:00
|
|
|
'theme-colors/no-literal-colors': 'error',
|
2022-04-27 05:44:13 -04:00
|
|
|
'translation-vars/no-template-vars': ['error', true],
|
2020-02-20 12:54:33 -05:00
|
|
|
camelcase: [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
allow: ['^UNSAFE_'],
|
|
|
|
properties: 'never',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'class-methods-use-this': 0,
|
2021-11-17 02:31:36 -05:00
|
|
|
curly: 2,
|
2020-02-20 12:54:33 -05:00
|
|
|
'func-names': 0,
|
|
|
|
'guard-for-in': 0,
|
|
|
|
'import/extensions': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
'.js': 'always',
|
|
|
|
'.jsx': 'always',
|
|
|
|
'.ts': 'always',
|
|
|
|
'.tsx': 'always',
|
|
|
|
'.json': 'always',
|
|
|
|
},
|
|
|
|
],
|
2020-09-14 02:59:02 -04:00
|
|
|
'import/no-cycle': 0, // re-enable up for discussion, might require some major refactors
|
2020-02-20 12:54:33 -05:00
|
|
|
'import/prefer-default-export': 0,
|
|
|
|
indent: 0,
|
2020-12-02 13:14:56 -05:00
|
|
|
'jsx-a11y/anchor-is-valid': 1,
|
2020-09-14 02:59:02 -04:00
|
|
|
'jsx-a11y/click-events-have-key-events': 0, // re-enable up for discussion
|
|
|
|
'jsx-a11y/mouse-events-have-key-events': 0, // re-enable up for discussion
|
2020-02-20 12:54:33 -05:00
|
|
|
'new-cap': 0,
|
|
|
|
'no-bitwise': 0,
|
|
|
|
'no-continue': 0,
|
|
|
|
'no-mixed-operators': 0,
|
|
|
|
'no-multi-assign': 0,
|
|
|
|
'no-multi-spaces': 0,
|
2021-02-28 13:10:15 -05:00
|
|
|
'no-nested-ternary': 0,
|
2020-02-20 12:54:33 -05:00
|
|
|
'no-prototype-builtins': 0,
|
|
|
|
'no-restricted-properties': 0,
|
2020-08-21 01:41:25 -04:00
|
|
|
'no-restricted-imports': [
|
2022-01-05 06:31:12 -05:00
|
|
|
'warn',
|
2020-08-21 01:41:25 -04:00
|
|
|
{
|
|
|
|
paths: [
|
|
|
|
{
|
|
|
|
name: 'antd',
|
|
|
|
message:
|
2022-04-27 00:12:43 -04:00
|
|
|
'Please import Ant components from the index of src/components',
|
2020-08-21 01:41:25 -04:00
|
|
|
},
|
2022-01-05 06:31:12 -05:00
|
|
|
{
|
|
|
|
name: '@superset-ui/core',
|
|
|
|
importNames: ['supersetTheme'],
|
|
|
|
message:
|
|
|
|
'Please use the theme directly from the ThemeProvider rather than importing supersetTheme.',
|
|
|
|
},
|
2020-08-21 01:41:25 -04:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2020-09-14 02:59:02 -04:00
|
|
|
'no-shadow': 0, // re-enable up for discussion
|
2020-02-20 12:54:33 -05:00
|
|
|
'padded-blocks': 0,
|
|
|
|
'prefer-arrow-callback': 0,
|
2020-04-03 20:05:16 -04:00
|
|
|
'prefer-object-spread': 1,
|
2020-09-14 13:11:20 -04:00
|
|
|
'prefer-destructuring': ['error', { object: true, array: false }],
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/destructuring-assignment': 0, // re-enable up for discussion
|
2020-02-20 12:54:33 -05:00
|
|
|
'react/forbid-prop-types': 0,
|
|
|
|
'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }],
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/jsx-fragments': 1,
|
2020-02-20 12:54:33 -05:00
|
|
|
'react/jsx-no-bind': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/jsx-props-no-spreading': 0, // re-enable up for discussion
|
2020-02-20 12:54:33 -05:00
|
|
|
'react/no-array-index-key': 0,
|
|
|
|
'react/no-string-refs': 0,
|
|
|
|
'react/no-unescaped-entities': 0,
|
|
|
|
'react/no-unused-prop-types': 0,
|
|
|
|
'react/prop-types': 0,
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/require-default-props': 0,
|
2021-01-10 20:26:35 -05:00
|
|
|
'react/sort-comp': 0, // TODO: re-enable in separate PR
|
2020-09-14 02:59:02 -04:00
|
|
|
'react/static-property-placement': 0, // disabled temporarily
|
2020-02-20 12:54:33 -05:00
|
|
|
'prettier/prettier': 'error',
|
|
|
|
},
|
2021-11-29 19:29:57 -05:00
|
|
|
ignorePatterns,
|
2020-02-20 12:54:33 -05:00
|
|
|
};
|