-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(NotificationBadge) warn about markup updated
- Loading branch information
1 parent
2db63e8
commit 215ec8f
Showing
6 changed files
with
64 additions
and
0 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
3 changes: 3 additions & 0 deletions
3
...es/v6/notificationBadgeWarnMarkupChange/notificationBadge-warn-markup-change.md
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,3 @@ | ||
### notificationBadge-warn-markup-change [(#10020)](https://github.com/patternfly/patternfly-react/pull/10020) | ||
|
||
The markup for NotificationBadge has changed, as it now uses stateful button internally. |
22 changes: 22 additions & 0 deletions
22
...c/rules/v6/notificationBadgeWarnMarkupChange/notificationBadge-warn-markup-change.test.ts
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,22 @@ | ||
const ruleTester = require('../../ruletester'); | ||
import * as rule from './notificationBadge-warn-markup-change'; | ||
|
||
ruleTester.run('notificationBadge-warn-markup-change', rule, { | ||
valid: [ | ||
{ | ||
code: `import { NotificationBadge } from '@someOtherPackage';`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { NotificationBadge } from '@patternfly/react-core';`, | ||
output: `import { NotificationBadge } from '@patternfly/react-core';`, | ||
errors: [ | ||
{ | ||
message: `The markup for NotificationBadge has changed, as it now uses stateful button internally.`, | ||
type: 'JSXOpeningElement', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
36 changes: 36 additions & 0 deletions
36
...ds/src/rules/v6/notificationBadgeWarnMarkupChange/notificationBadge-warn-markup-change.ts
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,36 @@ | ||
import { getFromPackage } from '../../helpers'; | ||
import { Rule } from 'eslint'; | ||
import { ImportDeclaration } from 'estree-jsx'; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10020 | ||
module.exports = { | ||
meta: {}, | ||
create: function (context: Rule.RuleContext) { | ||
const { imports } = getFromPackage(context, '@patternfly/react-core'); | ||
|
||
const notificationBadgeImport = imports.find( | ||
(specifier) => specifier.imported.name === 'NotificationBadge' | ||
); | ||
|
||
return !notificationBadgeImport | ||
? {} | ||
: { | ||
ImportDeclaration(node: ImportDeclaration) { | ||
if ( | ||
node.specifiers.find( | ||
(specifier) => | ||
specifier.type === 'ImportSpecifier' && | ||
specifier.imported.name === | ||
notificationBadgeImport.imported.name | ||
) | ||
) { | ||
context.report({ | ||
node, | ||
message: | ||
'The markup for NotificationBadge has changed, as it now uses stateful button internally.', | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
1 change: 1 addition & 0 deletions
1
...src/rules/v6/notificationBadgeWarnMarkupChange/notificationBadgeWarnMarkupChangeInput.tsx
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 @@ | ||
import { NotificationBadge } from '@patternfly/react-core'; |
1 change: 1 addition & 0 deletions
1
...rc/rules/v6/notificationBadgeWarnMarkupChange/notificationBadgeWarnMarkupChangeOutput.tsx
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 @@ | ||
import { NotificationBadge } from '@patternfly/react-core'; |