-
Notifications
You must be signed in to change notification settings - Fork 2.9k
refactor(eslint-rules): split consistent-base-hook into base-hook-signature + base-hook-no-forbidden-runtime #36251
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
Draft
Hotell
wants to merge
18
commits into
microsoft:master
Choose a base branch
from
Hotell:tools/ws-lint/split-consistent-base-hook
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f297ab5
feat(eslint-rules): add consistent-base-hook rule
Hotell 2ca0c42
chore(eslint-plugin): enable consistent-base-hook for v9 sources
Hotell 2c2c0e9
chore(react-components): suppress consistent-base-hook violations in …
Hotell cbbd8c5
feat(eslint-rules): allow useFocusWithin by default in consistent-bas…
Hotell a8ea39b
chore(react-components): drop now-unneeded consistent-base-hook suppr…
Hotell 153a636
feat(eslint-rules): allow useFocusVisible by default in consistent-ba…
Hotell 3504c3a
feat(eslint-rules): allow keyborg-only react-tabster APIs and drop ke…
Hotell 578c7da
chore(react-tooltip): drop now-unneeded consistent-base-hook suppress…
Hotell 338183a
feat(eslint-rules): auto-detect forbidden runtime deps via TS Program…
Hotell b4ed759
feat(eslint-rules): add allowTypeImports option to consistent-base-hook
Hotell 77938a0
style: encapsulate import tracking and apply explicit type imports/ig…
Hotell 6ada519
fix(eslint-rules): validate Ref import origin in consistent-base-hook…
Hotell dffca5a
revert(eslint-rules): undo unrelated import change in consistent-call…
Hotell 1084d65
feat(eslint-rules): detect type-leakage through watched packages in c…
Hotell f441aaf
feat(eslint-rules): extend consistent-base-hook with paired state hoo…
Hotell 4dd78a0
refactor(eslint-rules): split consistent-base-hook into base-hook-sig…
Hotell 07a9b99
refactor(eslint-rules): inline runtime helpers into base-hook-no-forb…
Hotell c7614a7
refactor(eslint-rules): inline base-hook-detector into each rule, dro…
Hotell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
4 changes: 4 additions & 0 deletions
4
tools/eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/src/dummy.ts
This file contains hidden or 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,4 @@ | ||
| // Placeholder so the tsconfig has an actual file to anchor the project. | ||
| // RuleTester test cases reference filenames inside this directory but their | ||
| // content comes from the inline `code` field. | ||
| export const dummy = 1; |
4 changes: 4 additions & 0 deletions
4
tools/eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/src/test.ts
This file contains hidden or 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,4 @@ | ||
| // Placeholder anchor for typed RuleTester cases. The actual code being linted | ||
| // comes from each test's inline `code` field; this file just needs to exist so | ||
| // that the fixture tsconfig's Program contains the filename used by tests. | ||
| export {}; |
5 changes: 5 additions & 0 deletions
5
tools/eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/stubs/cyclic-pkg/a.ts
This file contains hidden or 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,5 @@ | ||
| import { useB } from './b'; | ||
|
|
||
| export function useA(): number { | ||
| return useB() + 1; | ||
| } |
6 changes: 6 additions & 0 deletions
6
tools/eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/stubs/cyclic-pkg/b.ts
This file contains hidden or 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,6 @@ | ||
| import { useA } from './a'; | ||
|
|
||
| export function useB(): number { | ||
| // Pretend lazy ref to break true cycle at runtime; the static graph is cyclic. | ||
| return (useA as unknown as () => number).length; | ||
| } |
3 changes: 3 additions & 0 deletions
3
.../eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/stubs/cyclic-pkg/index.ts
This file contains hidden or 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,3 @@ | ||
| // Cyclic re-export — exercises the cycle-safety of the transitive walk. | ||
| export { useA } from './a'; | ||
| export { useB } from './b'; |
5 changes: 5 additions & 0 deletions
5
...lint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/stubs/heavy-runtime/index.ts
This file contains hidden or 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,5 @@ | ||
| export function runHeavy(): { tag: 'heavy' } { | ||
| return { tag: 'heavy' }; | ||
| } | ||
|
|
||
| export type HeavyOptions = { kind: 'heavy' }; |
3 changes: 3 additions & 0 deletions
3
...slint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/stubs/light-helper/index.ts
This file contains hidden or 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,3 @@ | ||
| export function runLight(_opts?: { mode: 'light' }): void { | ||
| /* noop */ | ||
| } |
7 changes: 7 additions & 0 deletions
7
...eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/stubs/watched-pkg/heavy.ts
This file contains hidden or 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,7 @@ | ||
| import { runHeavy } from 'heavy-runtime'; | ||
|
|
||
| export type HeavyType = { tag: 'heavy' }; | ||
|
|
||
| export function useHeavy(): HeavyType { | ||
| return runHeavy(); | ||
| } |
9 changes: 9 additions & 0 deletions
9
...eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/stubs/watched-pkg/index.ts
This file contains hidden or 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,9 @@ | ||
| import type { HeavyType } from './heavy'; | ||
|
|
||
| export { useHeavy } from './heavy'; | ||
| export { useLight } from './light'; | ||
| export type { LightOptions } from './light'; | ||
| // Re-export of a type-only thing from the heavy module — must not count as a runtime reach. | ||
| export type { HeavyType } from './heavy'; | ||
|
|
||
| export type HeavyWrapper = { tag: 'heavy-wrapper'; inner: HeavyType }; |
7 changes: 7 additions & 0 deletions
7
...eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/stubs/watched-pkg/light.ts
This file contains hidden or 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,7 @@ | ||
| import { runLight } from 'light-helper'; | ||
|
|
||
| export type LightOptions = { mode: 'light' }; | ||
|
|
||
| export function useLight(opts?: LightOptions): void { | ||
| runLight(opts); | ||
| } |
21 changes: 21 additions & 0 deletions
21
tools/eslint-rules/rules/__fixtures__/base-hook-no-forbidden-runtime/tsconfig.json
This file contains hidden or 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,21 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2022", | ||
| "module": "ESNext", | ||
| "moduleResolution": "node", | ||
| "lib": ["ES2022", "DOM"], | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "skipLibCheck": true, | ||
| "noEmit": true, | ||
| "baseUrl": ".", | ||
| "paths": { | ||
| "watched-pkg": ["./stubs/watched-pkg/index.ts"], | ||
| "watched-pkg/*": ["./stubs/watched-pkg/*"], | ||
| "heavy-runtime": ["./stubs/heavy-runtime/index.ts"], | ||
| "light-helper": ["./stubs/light-helper/index.ts"], | ||
| "cyclic-pkg": ["./stubs/cyclic-pkg/index.ts"] | ||
| } | ||
| }, | ||
| "include": ["src/**/*.ts", "src/**/*.tsx", "stubs/**/*.ts"] | ||
| } |
3 changes: 3 additions & 0 deletions
3
...int-rules/rules/__fixtures__/base-hook-signature/src/components/Sibling/useSiblingBase.ts
This file contains hidden or 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,3 @@ | ||
| export const useSiblingBase_unstable = (props: { a: number }, ref: React.Ref<HTMLElement>) => { | ||
| return { props, ref }; | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🕵🏾♀️ visual changes to review in the Visual Change Report
vr-tests-react-components/Charts-DonutChart 1 screenshots
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 1 screenshots
vr-tests-react-components/Positioning 2 screenshots
vr-tests-react-components/ProgressBar converged 3 screenshots
vr-tests-react-components/TagPicker 1 screenshots
vr-tests-web-components/Avatar 1 screenshots
vr-tests-web-components/RadioGroup 1 screenshots
vr-tests/Callout 2 screenshots
vr-tests/react-charting-LineChart 1 screenshots
There were 1 duplicate changes discarded. Check the build logs for more information.