-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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(eslint-plugin-react-components): add prefer-fluentui-v9 rule #33449
base: master
Are you sure you want to change the base?
feat(eslint-plugin-react-components): add prefer-fluentui-v9 rule #33449
Conversation
📊 Bundle size report✅ No changes found |
cc @NotWoods |
Pull request demo site: URL |
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/README.md
Outdated
Show resolved
Hide resolved
...es/react-components/eslint-plugin-react-components/etc/eslint-plugin-react-components.api.md
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
packages/react-components/eslint-plugin-react-components/src/rules/prefer-fluentui-v9.ts
Outdated
Show resolved
Hide resolved
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.
some comments that need to be addressed as part of PR but others can be a follow-up. approving to unblock once the change file is tweaked.
stoked to have 1st rule being shipped soon !
ty
}; | ||
|
||
const configs = { | ||
recommended: { | ||
plugins: [name], | ||
rules: { | ||
// add all recommended rules here | ||
[`@fluentui/react-components/${preferFluentUIV9Name}`]: 'warn', |
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.
wondering if this is good idea at this stage - any kind of modifications of config presets will be a breaking change for users. personally I'm fine having it as we properly follow semver.
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.
The preset usage is entirely optional. Consumers can always switch to individual rules if they prefer.
defaultOptions: [], | ||
create(context) { | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention |
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.
this goes in the way every time we wanna access AST, should we turn off this rule completely for rule implementation files ?
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.
done
@@ -1,7 +1,8 @@ | |||
{ | |||
"extends": "./tsconfig.json", | |||
"compilerOptions": { | |||
"module": "CommonJS", | |||
"module": "NodeNext", |
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.
type errors right ?
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.
yeah, typescript-eslint/utils doens't work well with the commonjs
ToggleButton: 'ToggleButton', | ||
Toggle: 'Switch', | ||
Tooltip: 'Tooltip', | ||
} satisfies Record<string, Migration>; |
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.
suggestion: it would be probably better to use 1 Schema ( more verbose ) so every value has component and package.
that would remove need of getMigrationDetails
completely
* Migrations from Fluent 8 components to Fluent 9 components. | ||
* @see https://react.fluentui.dev/?path=/docs/concepts-migration-from-v8-component-mapping--docs | ||
*/ | ||
const MIGRATIONS = { |
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.
wondering if we could generate this list by automation and update when we trigger stable release for v9 controll
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.
We can consider adding components to the map during the transition from preview to stable. However, we still need to define the relationship between the v8 and v9 components.
create(context) { | ||
return { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
ImportDeclaration(node) { |
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.
this will not work for lazy imports ( not sure how often that appears in user land with fluent but we should add it as a follow-up)
const lazyComponents = await import('@fluentui/react');
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.
Based on the example you gave, it's tough to do a static analysis to figure out which v8 components are used and suggest v9 alternatives. It might be doable, but I'm not sure if it's worth the effort. We could add a warning with a generic message, but I'm not sure how useful that would be.
@@ -0,0 +1,7 @@ | |||
{ | |||
"type": "minor", |
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.
this will be breaking change , we use zero based versioning for now -> so any feat/fix = patch
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.
done
6c824b5
to
0679d93
Compare
Previous Behavior
--
New Behavior
prefer-fluentui-v9
toeslint-plugin-react-components
to enforce the use of Fluent UI v9 equivalent for Fluent UI v8 components.recommended
config.Example of output:
Related Issue(s)