-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lint rule to disallow importing Route from react-router-dom (#24176)
## Summary & Motivation Adds a lint rule to disallow importing Route directly from react-router-dom. Instead it should be imported from our custom Route component that wraps the one from react-router-dom ## How I Tested These Changes jest test + ran `yarn lint --fix` which created the updated imports in this PR ## Changelog [New | Bug | Docs] NOCHANGELOG
- Loading branch information
Showing
18 changed files
with
338 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
module.exports = { | ||
extends: './index.js', | ||
overrides: { | ||
rules: { | ||
'@typescript-eslint/no-var-requires': 'off', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
js_modules/dagster-ui/packages/eslint-config/rules/__tests__/no-apollo-client.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-disable */ | ||
const {ESLintUtils, AST_NODE_TYPES} = require('@typescript-eslint/utils'); | ||
|
||
const ruleTester = new ESLintUtils.RuleTester({ | ||
parser: '@typescript-eslint/parser', | ||
}); | ||
|
||
const rule = require('../no-apollo-client'); | ||
|
||
ruleTester.run('rule', rule, { | ||
valid: [ | ||
` | ||
import {useQuery} from '../../apollo-client'; | ||
`, | ||
], | ||
invalid: [ | ||
{ | ||
code: ` | ||
import {useQuery} from '@apollo/client'; | ||
`, | ||
output: ` | ||
import {useQuery} from '@dagster-io/ui-core/apollo-client'; | ||
`, | ||
errors: [ | ||
{ | ||
type: AST_NODE_TYPES.ImportDeclaration, | ||
messageId: 'useWrappedApolloClient', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
35 changes: 35 additions & 0 deletions
35
js_modules/dagster-ui/packages/eslint-config/rules/__tests__/no-react-router-route.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable */ | ||
const {ESLintUtils, AST_NODE_TYPES} = require('@typescript-eslint/utils'); | ||
|
||
const ruleTester = new ESLintUtils.RuleTester({ | ||
parser: '@typescript-eslint/parser', | ||
}); | ||
|
||
const rule = require('../no-react-router-route'); | ||
|
||
ruleTester.run('rule', rule, { | ||
valid: [ | ||
` | ||
import {Redirect, Switch} from 'react-router-dom'; | ||
import {Route} from './Route'; | ||
`, | ||
], | ||
invalid: [ | ||
{ | ||
code: ` | ||
import {Redirect, Route, Switch} from 'react-router-dom'; | ||
`, | ||
output: ` | ||
import { Route } from '@dagster-io/ui-core/app/Route'; | ||
import {Redirect, Switch} from 'react-router-dom'; | ||
`, | ||
errors: [ | ||
{ | ||
type: AST_NODE_TYPES.ImportDeclaration, | ||
messageId: 'useDagsterRoute', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
d8d3c48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for dagit-core-storybook ready!
✅ Preview
https://dagit-core-storybook-abnokrgie-elementl.vercel.app
Built with commit d8d3c48.
This pull request is being automatically deployed with vercel-action