Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: import/order named not working with spread operator#3146

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
UnderKoen wants to merge2 commits intoimport-js:main
base:main
Choose a base branch
Loading
fromUnderKoen:fix/3145
Draft
Show file tree
Hide file tree
Changes fromall commits
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 deletionsrc/rules/order.js
View file
Open in desktop
Original file line numberDiff line numberDiff 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
9 changes: 9 additions & 0 deletionstests/files/order/spread-export.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
const test = {
a: 1,
browser: 2,
};

module.exports = {
...test,
platform: 'node',
};
23 changes: 23 additions & 0 deletionstests/src/rules/order.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,6 +23,11 @@ const rule = require('rules/order');

ruleTester.run('order', rule, {
valid: [
test({
code: `
import { platform, a, browser } from './order/spread-export';
`,
}),
// Default order using require
test({
code: `
Expand DownExpand Up@@ -3648,6 +3653,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 recognizeplatform 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 importsplatform and works, and one that importsa and/orbrowser 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

[8]ページ先頭

©2009-2025 Movatter.jp