jonlabelle / sublimejsprettier Goto Github PK
View Code? Open in Web Editor NEWJsPrettier is a Sublime Text Plug-in for Prettier, the opinionated code formatter.
License: MIT License
JsPrettier is a Sublime Text Plug-in for Prettier, the opinionated code formatter.
License: MIT License
I am trying to use this library in SublimeText, but I always get a Permission denied. I have change already ther permision of /usr/bin/prettier
but still got the same permission error. The error is this:
/usr/lib/nodejs /usr/bin/prettier --stdin --color=false --print-width 80 --single-quote=true --trailing-comma es5 --bracket-spacing=true --jsx-bracket-same-line=false --parser babylon --semi=true --tab-width 4 --use-tabs=false
error: JsPrettier - [Errno 13] Permission denied
Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 574, in run_
return self.run(edit)
File "/home/user-/.config/sublime-text-3/Packages/JsPrettier/JsPrettier.py", line 192, in run
source, node_path, prettier_cli_path, prettier_args)
File "/home/user-/.config/sublime-text-3/Packages/JsPrettier/JsPrettier.py", line 271, in run_prettier
shell=self.is_windows())
File "./python3.3/subprocess.py", line 819, in __init__
File "./python3.3/subprocess.py", line 1448, in _execute_child
PermissionError: [Errno 13] Permission denied
Prettier version: 1.3.1
JsPrettier version: 1.7.8
Platform: Ubuntu 16.04
Node version: 6.10.0
Sublime version: 3
Sublime build: 3114
This is my sublime settings
{
"debug": true,
"prettier_cli_path": "/usr/bin/prettier",
"node_path": "/usr/lib/nodejs",
"auto_format_on_save": true,
"allow_inline_formatting": false,
"prettier_options": {
"printWidth": 80,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"parser": "babylon",
"useTabs": true,
"tabWidth": 4,
}
}
Sometimes I have to dive into the node_modules
, placing console.log
commands to debug. Having the auto_format_on_save
to true
will format that file which is somewhat undesirable.
Alternatively, an include
option would also work too.
Cheers! ๐
Trailing commas (regardless of your setting) should not be enabled for JSON files because it creates invalid JSONs. This is an issue when you have "auto_format_on_save": true
I know you can now use .sublime-project file but it would be nice if this plugin tried first to look it up in .eslintrc
:
After a fresh installation of the plug-in and a fresh installation of prettier (0.11.0) as well, executing the formatting command doesn't work, the code is not formatted at all. This has nothing to do with finding prettier path, I am pretty sure of it.
The following message is displayed in the sublime console:
Traceback (most recent call last):
File "/Applications/Sublime.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
return self.run(edit)
File "/Users/a/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 60, in run
prettier_options)
File "/Users/a/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 98, in run_prettier
prettier_cli_opts = self.parse_prettier_option_cli_map(prettier_options)
File "/Users/a/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 222, in parse_prettier_option_cli_map
option = prettier_options[mapping['option']]
KeyError: 'printWidth'
In most cases I can not re-format the whole file. I would however like to format code that I've just added to a file, in other words, select that code and format the selection.
When trying to run the plugin it appears that the plugin is not reading the node_path in the settings to retrieve the correct location of node (I'm using nvm). I get the same message whether I put the location in the default, or user settings file. I also get the same error when the node_path field is left empty.
OS: macOS 10.11.6
Sublime build: 3126
For reference, the node_path value is:
"node_path": ":/Users/Tim/.nvm/versions/node/v6.4.0/bin"
Here is the error output in the console:
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
return self.run(edit)
File "/Users/Tim/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 50, in run
if not self.is_global_prettier_installed():
File "/Users/Tim/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 148, in is_global_prettier_installed
if which('prettier', self.get_node_path()) is None:
File "/Users/Tim/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 142, in get_node_path
if os.path.isdir(node_path):
File "./python3.3/genericpath.py", line 41, in isdir
TypeError: can't specify None for path argument
With prettier 1.5.2 we can now format json by using --parser json
It would be great if this fantastic plugin could support formatting json files through prettier by using the --parser json
option
As a user, I want my json files to be formatted to the same standard as my js files
1.5.2
1.10.12
Thanks for creating this plugin ๐
I wonder if a future release might have a format on save option?
Currently figuring out where I should point "node_path", but thinking that needing to update that whenever I wanted to switch node versions seems pretty annoying.
Any reason it can't just pick up prettier
from my current $PATH
?
After installation on a MacOSX with Sublime Text 3, also using NVM the following errors appears:
https://www.dropbox.com/s/gugnk094gph6s1o/Captura%20de%20tela%202017-06-18%2002.01.58.png?dl=0
I tried to install prettier using sudo, changing the permissions folder... no success.
It would be nice to have an option that will allow auto_format_on_save
only when prettier
is in package dependencies, so there's no need to setup .sublime-project
for each project.
The plugin is disabled on .vue
and .tag
files, which are similar to JSX files in vuejs and riotjs projects. The sublime syntax for .vue
and .tag
files mark script block as source.js
Right now, JsPrettier only formats files that end in .js
or .jsx
. That's totally cool for probably most people, but a good chunk of those in the Rails community are using jsx with interpolated ERB, still. Such filenames look like component.js.jsx.erb
. ERB doesn't affect prettier's ability to format the code at all, and it works completely out of the box. In my project, I run something like:
prettier --write "app/assets/javascripts/components/*.jsx*"
to format exactly the files in question.
Would it be possible to allow an option to pick which file extensions are formatted on save to JsPrettier?
When working in TypeScript, with auto_format_on_save
on, the Prettier plugin has a hard time formatting certain lines of my code. For example:
require<any>('version-sort');
becomes
require < any > 'version-sort';
which then throws compiler errors.
When I add "parser": "typescript",
, the issue is fixed, but I expected it to automatically know it was a Typescript file because of:
Prettier automatically infers the parser from the input file path, so you shouldn't have to change this setting. -- from Parser Options
1.10.0
- Sublime Text Version: 3
- Sublime Text Build: 3126
- Operating System Name: macOS Sierra
- Operating System Version: 10.12.5
<project_name>.sublime-project
file (if applicable) "prettier_cli_path": "node_modules/.bin/prettier",
"js_prettier": {
"auto_format_on_save": true,
"prettier_options": {
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all",
}
}
require<any>('version-sort');
require<any>('version-sort');
becomes
require < any > 'version-sort';
when it should have stayed the same
Prettier version
$ prettier --version
1.1.0
JsPrettier version (package.json)
"name": "sublime-js-prettier",
"version": "1.7.4",
Prettier command line arguments (enable the debug
setting and open the ST console)
/usr/local/bin/prettier --stdin --color=false --print-width 80 --single-quote=false --trailing-comma none --bracket-spacing=true --jsx-bracket-same-line=false --parser babylon --semi=true --tab-width 4 --use-tabs=false
Is the same behavior observed when run against Prettier directly from the
command line? For example, to pass the contents of file path_to_js_file.js
to
Prettier from the command line.
Yes, but the issue is with what's being sent, not the output.
Steps to reproduce the behavior
1. Open a JavaScript file. Under the Sublime Text menu, select Preferences then Settings โ Syntax Specific
2. Set or verify tab_size equal to 2
3. Under Sublime Text Default or User settings, verify that tab_size is equal to a value other than 2.
4. Run the JsPrettier sublime command on the JavaScript file from the command palette
5. The tab_size value from the default/user settings is used instead of the value from the syntax specific settings.
Firstly, thank you for jumping on making prettier work with sublime. Much appreciated!
However, currently if there is something that can't be parsed in the source file then this package will throw up a dialog with the entire prettier traceback. That traceback is largely useless to understand where the code doesn't parse, but pretty annoying, especially when the package is set to run prettier on save. I'm wondering if there's a more subtle alternative?
When saving a js file while having the auto-format-on-save flag set to true, the plug-in does its job wonderfully.
Now, if the save action was initiated while having a piece of code selected/highlighted, the plug-in for some reason overwrite the whole thing before formatting it and cause it to break. I find this issue to be very frustrating, it would be great if there was a workaround it.
Example:
This is specific to the plug-in and not to the formatter itself.
wrong repo
Prettier will soon have support for workspace configuration with files like .prettierrc
and a couple other configuration methods described here:
https://github.com/prettier/prettier#configuration-file
The merged pull request is here: prettier/prettier#2434
However it hasn't been released yet.
Could you make any modifications necessary such that the SublimeJsPrettier settings will have a lower priority than the workspace configs?
The recent support for CSS has made this plugin unusable for me. I have custom .SASS files and it's formatting them incorrectly. I only want it to run on JS and JSX but that apparently isn't an option now.
This is the error I get when I run the command:
/usr/local/lib/node_modules/prettier/bin/prettier.js:4
const fs = require("fs");
^^^^^
SyntaxError: Use of const in strict mode.
Any help?
When reporting an issue, please include the following information in your post:
stdin: SyntaxError: Unexpected token (4:30)
Prettier version
JsPrettier version
1.7.0
Platform details
The generated Prettier command line arguments
Steps to reproduce the behavior
just format the .vue file in sublime
Is the same behavior observed when run against Prettier directly?
Yes
I have auto_format_on_save
enabled in one of my projects, and was tweaking a transpiled bundle.js
file, only to find that prettier (unsurprisingly) choked on the 300,000 line file. While such cases are rare, they are not nonexistent.
I would propose a solution along the lines of that found in the Trailing Spaces
package's trailing_spaces_file_max_size
option. Please consider it if you have some time.
With a project without prettier installed, and auto_format_on_save: true
I get pop-ups every time I save until I set auto_format_on_save: false
. I understand the errors are helpful when debugging, but I'd rather have them appear in the console bar, hidden entirely, or somewhere less intrusive.
Is it possible to add an option to silence errors?
Maybe:
error_volume: dialog|console|silent
Prettier version: 1.5.3
JS Prettier version: 1.12.0
Sublime: Stable Channel, Build 3126
OS: Mac: Sierra 10.12.6
"js_prettier":
{
"auto_format_on_save": true,
"prettier_options":
{
"printWidth": 120,
"singleQuote": true,
"trailingComma": "all"
}
},
auto_format_on_save: true
Code style standards vary from project to project, so it would be helpful for the "prettier_options"
setting to be configurable per-project, by including the settings in the .sublime-project file.
Example:
{
"folders":
[
{
"path": "."
}
],
"settings":
{
// not here - this section overrides core Sublime Text settings
},
"prettier_options": {
"singleQuote": true,
"trailingComma": true
}
}
Settings in the project file should override both the package default settings and the user settings file.
The JSON of the project file may be accessed via the Sublime Text API with window.project_data()
.
I haven't gotten a chance to really dive into debugging this yet, but simply running through the install instructions is giving me an error when I try and run the command for the first time.
I verified Prettier was installed and restarted sublime with the same issue.
Also, upon opening the package settings for the first time both the default and user files are empty.
EDIT: I forgot to mention that prettier is working via the CLI if that helps.
After installing prettier and following the instructions I was hitting this issue:
/Users/ml/.nvm/versions/node/v4.4.4/lib/node_modules/prettier/bin/prettier.js:5
const fs = require("fs");
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:935:3
I wasn't sure what the problem was. After some digging, I found that I needed to have my node environment for sublime (for me project specific) as prettier
was installed with. Setting this in my .sublime-project file solved it for me:
"settings": {
"js_prettier": {
"prettier_cli_path": "/Users/ml/.nvm/versions/node/v4.4.4/bin/prettier",
"node_path": "/Users/ml/.nvm/versions/node/v4.4.4/bin/node"
}
}
This was not super obvious to me. Could this be documented clearer somewhere?
Related issue: prettier/prettier#99 (comment)
Setting trailing comma to none does not turn off trailing commas. The off command is a boolean value. Seems to be an issue in prettier itself.
CLI args:
['--print-width', '80', '--single-quote=true', '--trailing-comma', 'none', '--bracket-spacing=true', '--jsx-bracket-same-line=false', '--parser', 'babylon', '--tab-width', '4']
FIX args:
['--print-width', '80', '--single-quote=true', '--trailing-comma=false', '--bracket-spacing=true', '--jsx-bracket-same-line=false', '--parser', 'babylon', '--tab-width', '4']
FYI only.
Hi, thanks for the plugin!
I have a little issue with the bracketSpacing option that's not working, it stays at true.
My config:
{
//
// @prettier_cli_path { string | default = "" }
//
// It's strongly recommended to leave the "prettier_cli_path" value
// empty "", however if Sublime Text has problems resolving the path
// to the `prettier` cli executable, you can explicitly specify the
// value here.
//
// Examples:
//
// - macOS/Linux...: "/path/to/node_modules/.bin/prettier"
// - Windows.......: "C:/path/to/npm/prettier"
"debug": true,
"prettier_cli_path": "/usr/local/Cellar/node/6.8.1/bin/prettier",
//
// @auto_format_on_save { bool | default = false }
//
// Run js_prettier command automatically
// when JavaScript files are saved.
"auto_format_on_save" : false,
//
// For a complete list of supported options and acceptable values,
// please reference the `prettier` documentation at https://github.com/jlongster/prettier
"prettier_options": {
// Fit code within this line limit
"printWidth": 99,
// Number of spaces it should use per tab
"tabWidth": 4,
// If true, will use single instead of double quotes
"singleQuote": false,
// Controls the printing of trailing commas wherever possible. Valid options:
// "none" - No trailing commas
// "es5" - Trailing commas where valid in ES5 (objects, arrays, etc)
// "all" - Trailing commas wherever possible (function arguments)
//
// NOTE: Above is only available in 0.19.0 and above. Previously this was
// a boolean argument.
"trailingComma": "es5",
// Controls the printing of spaces inside object literals
"bracketSpacing": false,
// If true, puts the `>` of a multi-line jsx element at the end of
// the last line instead of being alone on the next line
"jsxBracketSameLine": true,
// Which parser to use. Valid options are 'flow' and 'babylon'
"parser": "babylon",
}
}
CLI output:
-----------------------------------------
JsPrettier DEBUG - Prettier CLI Command
-----------------------------------------
/usr/local/Cellar/node/6.8.1/bin/prettier --stdin --color=false --print-width 99 --single-quote=false --trailing-comma es5 --bracket-spacing=true --jsx-bracket-same-line=true --parser babylon --tab-width 4
I looked at the source but couldn't find any typo. Any ideas?
In JavaScript projects with prettier
as dev-dependency (package.json
) inside the node_modules
folder of the project, it would be great to use this version of prettier
.
Something like this in a *.sublime-project
file:
{
"folders": [{ "path": "." }],
"settings" : {
"js_prettier": {
"auto_format_on_save": true,
"prettier_cli_path": "./node_modules/.bin/prettier"
}
}
Or maybe its possible to automatically find the first node_modules
folder inside a project and use that prettier
, otherwise use the globally installed version of prettier
.
I upgraded prettier to 1.6.0 and tried to run JsPrettier. It didn't format and I got this error:
------------------
JsPrettier ERROR
------------------
Prettier reported the following error:
Ignored unknown option: --single-quote=true
Ignored unknown option: --bracket-spacing=true
Ignored unknown option: --jsx-bracket-same-line=false
Ignored unknown option: --semi=true
Ignored unknown option: --use-tabs=true
Process finished with exit code 0
This may be related to prettier's adoption of a .prettierrc file in version 1.6 to replace other configuration options, possibly including these arguments.
1.6.0
1.12.12
- Sublime Text Build: 3126
- Operating System Name: Mac OS
- Operating System Version: 10.11.6 El Capitan
-----------------------------------------
JsPrettier DEBUG - Prettier CLI Command
-----------------------------------------
/usr/local/bin/prettier --stdin --print-width 80 --single-quote=true --trailing-comma none --bracket-spacing=true --jsx-bracket-same-line=false --parser babylon --semi=true --tab-width 4 --use-tabs=false
I get the ignored parameters warnings, but Prettier also outputs the formatted file.
User/JsPrettier.sublime-settings
file{
"prettier_options": {
"singleQuote": true
}
}
1. Upgrade prettier
2. Run JsPrettier on a file
Expected behavior: it formats the file.
Actual behavior: It doesn't, outputs an error.
I would like super+b to run prettier, then eslint --fix so it keeps my formatting.
Using Sublime Text dev 3125. OS X 10.11.6.
Most files, when running jsPrettier I get this in the console:
------------------
JsPrettier Error
------------------
stdin: RangeError: Invalid string length
The files it does run on are formatting crazy. Below is some sample code. This is how it was typed in sublime:
var TopNav = function () {
var swiper, topNavPref;
function ready () {
Settings.SetItem("topnav-hidden", { /*description: "Cross-sell navigation is hidden by default",*/ storage: "local", type: "Boolean"});
topNavPref = Settings.GetItem("topnav-hidden");
if(topNavPref) {
document.body.removeAttribute("data-topnav");
} else {
document.body.setAttribute("data-topnav", "");
}
document.body.addEventListener("touchstart", function (e) {
if(e.touches[0].clientY < 90) {
startSwipe(e);
}
});
setUpClicks();
};
};
And this is how it looks after running jsPrettier on it via Sublime (note: had to delete some from the bottom of the output because of the length restriction here):
var TopNav = function() {
var swiper, topNavPref;
function ready() {
Settings.SetItem(
"topnav-hidden",
{
/*description: "Cross-sell navigation is hidden by default",*/
storage: "local",
type: "Boolean"
}
);
And here is the same code run through the online version:
var TopNav = function() {
var swiper, topNavPref;
function ready() {
Settings.SetItem("topnav-hidden", {
/*description: "Cross-sell navigation is hidden by default",*/
storage: "local",
type: "Boolean"
});
topNavPref = Settings.GetItem("topnav-hidden");
if (topNavPref) {
document.body.removeAttribute("data-topnav");
} else {
document.body.setAttribute("data-topnav", "");
}
document.body.addEventListener("touchstart", function(
e
) {
if (e.touches[0].clientY < 90) {
startSwipe(e);
}
});
setUpClicks();
}
};
If there is anything further I can do to help diagnose let me know :)
Looks like the trim_trailing_line_breaks
is also removing the newline at EOF. I had originally filed an issue on the main Prettier repo prettier/prettier#708 but ended up tracking it down to that function.
I noticed a few commits around removing line breaks, so I'm not quite sure what the solution would be for leaving the EOF new line.
I attempted to change \Z
to \z
which seemed to work, but not sure what the fallout is for the other line breaks you were seeing.
I'd like to propose a new option to include files (e.g. auto_format_on_save_includes
).
In the case of a project I'm working on it would be more convenient to have an opt-in behavior instead of the currently available opt-out auto_format_on_save_excludes
.
As using prettier has a potentially destructive behavior, I would feel safer if I could add a file to prettier on save when I notice it's not being prettified.
In case this option is not specified, the behavior would be as it is currently - all supported files would be autosaved.
Doesn't work with the latest 1.6.0 version of Prettier (works great with previous versions).
Here is the error in ST console:
------------------
JsPrettier ERROR
------------------
Prettier reported the following error:
Ignored unknown option: --single-quote=false
Ignored unknown option: --bracket-spacing=true
Ignored unknown option: --jsx-bracket-same-line=false
Ignored unknown option: --semi=true
Ignored unknown option: --use-tabs=false
Thank you very much for your work.
Currently i want to run eslint --fix
after prettier done its job. Anyone knows how to do it?
node v 7.10.1
npm 5.3
ubuntu 16.04
sublime 3, latest build
JsPrettier DEBUG - Prettier CLI Command
/usr/bin/prettier --stdin --print-width 80 --single-quote=false --trailing-comma none --bracket-spacing=true --jsx-bracket-same-line=false --parser babylon --semi=true --tab-width 2 --use-tabs=false
JsPrettier ERROR
Prettier reported the following error:
Ignored unknown option: --single-quote=false
Ignored unknown option: --bracket-spacing=true
Ignored unknown option: --jsx-bracket-same-line=false
Ignored unknown option: --semi=true
Ignored unknown option: --use-tabs=false
Process finished with exit code 0
Explain the issue
JsPrettier sometimes throws an error that there are too many open files.
Explain the issue with as much detail as possible...
The issue seems to happen after Sublime has been open for a while, and after I have opened / saved / closed a lot of files, though I couldn't say exactly how long it takes for the error to occur.
The error presents as a pop-up window:
Once the error has occurred, Prettier will not run again (the error will happen every time) until Sublime has been restarted.
Prettier version (command line)
1.1.0
JsPrettier version (package.json)
"name": "sublime-js-prettier",
"version": "1.7.8",
Platform details
- Sublime Text Version: 3
- Sublime Text Build: 3126
- Operating System Name: Mac OS X
- Operating System Version: 10.12.5 (issue also observed on 10.10.x)
Prettier arguments
"auto_format_on_save": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true
Otherwise I use the defaults.
Is the same behavior observed when run against Prettier directly?
N/A
Steps to reproduce the behavior
Debug output
-----------------------------------------
JsPrettier DEBUG - Prettier CLI Command
-----------------------------------------
/Users/edavies/npm-global/bin/prettier --stdin --color=false --print-width 80 --single-quote=true --trailing-comma es5 --bracket-spacing=true --jsx-bracket-same-line=false --parser babylon --semi=true --tab-width 2 --use-tabs=false
error: JsPrettier - [Errno 24] Too many open files
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 812, in run_
return self.run(edit, **args)
File "/Users/edavies/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 192, in run
source, node_path, prettier_cli_path, prettier_args)
File "/Users/edavies/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 271, in run_prettier
shell=self.is_windows())
File "./python3.3/subprocess.py", line 784, in __init__
File "./python3.3/subprocess.py", line 1281, in _get_handles
OSError: [Errno 24] Too many open files
The newest release of prettier added support for typescript and css files. https://github.com/prettier/prettier/releases/tag/1.4.0
Currently, it's only possible to execute the JsPrettier command in javascript files.
When I run JsPrettier nothing happens and I get an error in the console.
I installed JsPrettier using npm install -g prettier
My config:
{
"prettier_cli_path": "/Users/nils/.nvm/versions/node/v6.5.0/bin/prettier",
"prettier_options": {
"printWidth": 80,
"singleQuote": true,
"trailingComma": true
}
}
The error I get:
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
return self.run(edit)
File "/Users/nils/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 60, in run
prettier_options)
File "/Users/nils/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 99, in run_prettier
prettier_cli_opts = self.parse_prettier_option_cli_map(prettier_options)
File "/Users/nils/Library/Application Support/Sublime Text 3/Packages/JsPrettier/JsPrettier.py", line 250, in parse_prettier_option_cli_map
option = prettier_options[mapping['option']]
KeyError: 'bracketSpacing'
Any idea what could cause this?
Hi! Thank you for the plugin, it works great! Could you add a shortcut key? Invoking Prettier through the menu is pretty slow. Thanks!
Prettier version
1.1.0
JsPrettier version (package.json)
"version": "1.7.4",
My Prettier.sublime-settings file looks like:
{
"prettier_cli_path": "$HOME/.nvm/versions/node/v7.9.0/bin/prettier"
}
(which exists and executes fine)
however when running the installed plugin it get the following in the sublime console
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
return self.run(edit)
File "/Users/callum.rogan/Library/Application Support/Sublime Text 3/Packages/sublime-prettier/prettier.py", line 67, in run
prettify_code(edit, self.view, region)
File "/Users/callum.rogan/Library/Application Support/Sublime Text 3/Packages/sublime-prettier/prettier.py", line 45, in prettify_code
shell=IS_WINDOWS
File "./python3.3/subprocess.py", line 819, in __init__
File "./python3.3/subprocess.py", line 1448, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'prettier'
Seems like an issue with the update of the Prettier CLI, but it affects this plugin.
The sublime console is returning this error
## Prettier CLI Error Output:
Ignored unknown option: --jsx-bracket-same-line=false
## Prettier CLI Return Code:
0
Explain the issue
Running Format JavaScript
empties file.
Prettier version (command line)
$ prettier --version
1.4.2
JsPrettier version (package.json)
...
"name": "sublime-js-prettier",
"version": "1.4.2",
...
Platform details
- Sublime Text Version: 3
- Sublime Text Build: 3133
- Sublime Text Architecture: What is this?
- Operating System Name: Ubuntu
- Operating System Version: 16.04
- Operating System Architecture: 64bit
Prettier command line arguments (enable the debug setting and open the Sublime Text console to view the cli args passed to Prettier)
/usr/bin/nodejs /home/phil/.npm-global/lib/node_modules/prettier \
--stdin \
--color=false \
--print-width 80 \
--single-quote=false \
--trailing-comma none \
--bracket-spacing=true \
--jsx-bracket-same-line=false \
--parser babylon \
--semi=true \
--tab-width 4 \
--use-tabs=false
Is the same behavior observed when run against Prettier directly? For example, to pass the contents of file path_to_js_file.js
to Prettier from the command line.
No, nothing happens. The file is not transformed at all.
Steps to reproduce the behavior
A file x.js
containing the following will be emptied upon formatting.
function hello() {
console.log("x")
}
First of all, thanks for integrating prettier in Sublime Text.
As it turns out prettier is going to support (not released as of today) its own editor-independent configuration soon: prettier/prettier#2434
Would be great if SublimeJsPrettier would support this as its main configuration source. Thus the prettier configuration that should apply for a project would only need to be defined in a single place and it would not be necessary for each developer to configure its own editor/IDE to use prettier with the right options (e.g. not every developer might use Sublime Text).
I'm not sure though how this would be best implemented in SublimeJsPrettier.
Not sure if doing a backwards-incompatible change of only using prettier's config would be a possible way to go. Would probably be the easiest way in the long run as it would involve less maintenance on SublimeJsPrettier side (e.g. when new prettier options are introduced).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.