Running with mobx decorator got error
See original GitHub issueError messages are as follows:
SyntaxError: This experimental syntax requires enabling one of the following parser plugin(s): 'decorators-legacy, decorators' (20:0)
...
 at Object._raise (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:816:17)
    at Object.raiseWithData (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:809:17)
    at Object.expectOnePlugin (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:9920:18)
    at Object.parseDecorator (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:12727:10)
    at Object.parseDecorators (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:12709:30)
    at Object.parseStatement (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:12542:12)
    at Object.parseBlockOrModuleBlockBody (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:13134:25)
    at Object.parseBlockBody (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:13125:10)
    at Object.parseProgram (.../node_modules/@trivago/prettier-plugin-sort-imports/node_modules/@babel/parser/lib/index.js:12468:10)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
Trying to install MobX but getting decorators error when start ...
When I install Mobx and Mobx react I am getting the following error. ./src/index.js Error: The 'decorators' plugin requires a ...
Read more >Enabling decorators · MobX
When migrating from MobX 4/5 to 6, we recommend to always run the code-mod, to make sure the necessary makeObservable calls are generated....
Read more >mobx-undecorate - npm
mobx -undecorate. Converts MobX 5 to MobX 6 code. Running this code mod: Go to the folder with your source files and run...
Read more >Common Pitfalls & Best Practices · Mobx Doc - iiunknown
Importing from wrong location · Issues with decorators? · Array.isArray(observable([1,2,3])) === false · object.someNewProp = value is not picked up.
Read more >MobX (with Decorators) in create-react-app - Robin Wieruch
Running this code in a plain create-react-app application will yield a Unexpected token error in the developer console. You would have to add ......
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

The solution to support both decorator plugins it was to support none by default, but with the new option added (
importOrderParserPlugins) you can override that default config, no?Now
prettier, withoutprettier-plugin-sort-imports, can successfully format the next code:But if you install
prettier-plugin-sort-imports:Adding the plugins to
importOrderParserPluginsfixes the issue, but was it mandatory requirement delete the default plugins?Hey @fangwei18 and @juanrgm, sorry that you are facing this issue. As you know, we were adding few babel parser plugins by default in version 2,
legacy-decorator,typescriptandjsx. The issue is there are other proposals for decorators and passing 2 parser plugins to babel for the decorators is not possible. Therefore we decided to let the user decides what parser to pass. To solve the issue, you should create a. prettierrcfile and pass properimportOrderParserPluginsvalue. I’m going to close the issue, but if you have other problems with the plugin, feel free to open a new issue.