Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,9 @@ module.exports = {
if (node.right.type === 'ObjectExpression') {
for (let i = 0; i < node.right.properties.length; i++) {
if (
node.right.properties[i].key.type !== 'Identifier'
!node.right.properties[i].key
|| node.right.properties[i].key.type !== 'Identifier'
|| !node.right.properties[i].value
|| node.right.properties[i].value.type !== 'Identifier'
) {
return;
Expand Down
18 changes: 18 additions & 0 deletions tests/src/rules/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -3648,6 +3648,24 @@ flowRuleTester.run('order', rule, {
import typeof {foo} from 'common';
import {bar} from 'common';
`,
}),
test({
options: [
{
named: true,
},
],
code: `
const test = {
a: 1,
browser: 2,
};

module.exports = {
...test,
platform: 'node',
};
`,
Comment on lines +3657 to +3673
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like to also include a test that demonstrates that we only recognize platform as a named export from this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not that familiar with this codebase. How could I test this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'd want to make a fixture file with this test code in it, and then make two test cases that import this test file - one that imports platform and works, and one that imports a and/or browser and fails.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im very sorry but can't figure it out. I added the cases but it doesn't fail? I suspect that I'm doing something wrong but cant figure out what.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you push up what you have? I'll take a look.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried looking at #3032 as it had fixture files I believe

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb did you have a chance to look?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

})],
invalid: [
test({
Expand Down
Loading