Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(linting): restrict direct use of supersetTheme in favor of ThemeProvider #17001

Merged
merged 2 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion superset-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,20 @@ module.exports = {
'no-prototype-builtins': 0,
'no-restricted-properties': 0,
'no-restricted-imports': [
'error',
'warn',
{
paths: [
{
name: 'antd',
message:
'Please import Ant components from the index of common/components',
},
{
name: '@superset-ui/core',
importNames: ['supersetTheme'],
message:
'Please use the theme directly from the ThemeProvider rather than importing supersetTheme.',
},
],
},
],
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/spec/helpers/theming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import { shallow as enzymeShallow, mount as enzymeMount } from 'enzyme';
// eslint-disable-next-line no-restricted-imports
import { supersetTheme } from '@superset-ui/core';
import { ReactElement } from 'react';
import { ProviderWrapper } from './ProviderWrapper';
Expand Down
13 changes: 12 additions & 1 deletion superset-frontend/src/common/components/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
*/
{
"rules": {
"no-restricted-imports": 0
"no-restricted-imports": [
"warn",
{
"paths": [
{
"name": "@superset-ui/core",
"importNames": ["supersetTheme"],
"message": "Please use the theme directly from the ThemeProvider rather than importing supersetTheme."
}
]
}
]
}
}
15 changes: 14 additions & 1 deletion superset-frontend/src/components/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
*/
{
"rules": {
"no-restricted-imports": 0
"no-restricted-imports": [
"warn",
{
"paths": [
{
"name": "@superset-ui/core",
"importNames": [
"supersetTheme"
],
"message": "Please use the theme directly from the ThemeProvider rather than importing supersetTheme."
}
]
}
]
}
}
1 change: 1 addition & 0 deletions superset-frontend/src/preamble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { setConfig as setHotLoaderConfig } from 'react-hot-loader';
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
import moment from 'moment';
// eslint-disable-next-line no-restricted-imports
import { configure, supersetTheme } from '@superset-ui/core';
import { merge } from 'lodash';
import setupClient from './setup/setupClient';
Expand Down