Replies: 4 comments 4 replies
-
It's not actually a Next thing, it's a React Server Component convention - reactjs/rfcs#227. Right now we can't use this with this plugin. |
Beta Was this translation helpful? Give feedback.
-
PR at #186
@oliveiraantoniocc It appears statements like |
Beta Was this translation helpful? Give feedback.
-
Hey, the pattern of using a literal string at the top of some method isn't unique to the file -- some libraries and systems use it as a directive for a function. For example, the "use strict" directive which can be local to a function: function myStrictFunction() {
// Function-level strict mode syntax
"use strict";
function nested() {
return "And so am I!";
}
return `Hi! I'm a strict mode function! ${nested()}`;
}
function myNotStrictFunction() {
return "I'm not strict.";
} Or, in the case of a library like react-native-reanimated, worklets are defined by the function body: function someWorklet(greeting) {
'worklet';
console.log("Hey I'm running on the UI thread");
} So, extracting all those and throwing them to the source root doesn't work. Blanket moving raw string literals around probably breaks a number of silly assumptions folks make. A couple solutions could be:
|
Beta Was this translation helpful? Give feedback.
-
Any chance we can get a bump/review on the pr #198 @ayusharma / @oliveiraantoniocc? Been a month or so |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
React 18 introduced a
'use client';
statement to be added at the top of files that render on the client. However this plugin moves it below imports, preventing React from detecting the statement.Example:
I think the ideal solution for this plugin would be to ignore any lines containing just a string literal and/or lines marked with
// prettier-ignore
.Beta Was this translation helpful? Give feedback.
All reactions