Skip to content

Commit 217cfd7

Browse files
committed
Add optional chain to return
1 parent 7f30d22 commit 217cfd7

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

.changeset/proud-terms-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-primer-react': patch
3+
---
4+
5+
Fixes error when `imported` does not exist in specifier object

src/rules/__tests__/no-deprecated-experimental-components.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ ruleTester.run('no-deprecated-experimental-components', rule, {
2424
{
2525
code: `import {DataTable, ActionBar} from '@primer/react/experimental'`,
2626
},
27+
{
28+
code: `import * as RandomComponent from '@primer/react/experimental'`,
29+
},
2730
],
2831
invalid: [
2932
// Single experimental import

src/rules/no-deprecated-experimental-components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
const entrypoint = entrypoints.get(node.source.value)
4343

4444
const experimental = node.specifiers.filter(specifier => {
45-
return entrypoint.has(specifier.imported.name)
45+
return entrypoint.has(specifier.imported?.name)
4646
})
4747

4848
const components = experimental.map(specifier => specifier.imported.name)

0 commit comments

Comments
 (0)