Comments (10)
@github0013 that behavior is fixed on master and is going to be released soon. The #prettier-ignore
behavior is after that. A PR would be welcome as well.
from plugin-ruby.
Ahh @valscion thanks for the reminder - I had forgotten to activate that. That's now in #725 and will be out in the next version.
from plugin-ruby.
@kddeisz I'm good to send a PR for this, would appreciate your thoughts on #104 (comment)
I also think this implementation will be impacted by comment handling 🤔
from plugin-ruby.
Hm; Tempted to take a look at this as I can see that Prettier has an escape hatch built in for this if the printer provides an implementation of hasPrettierIgnore
:
I'm thinking the implementation should look something like this:
const hasIgnoreComment = path => {
const node = path.getValue();
return (
node &&
Array.isArray(node.body) &&
node.body.some(
node =>
node && node.type === "@comment" && node.body === "# prettier-ignore"
)
);
};
We'll also want to implement locStart
and locEnd
within the prettier ruby parser to slice out the original string. That way we can provide access to the node's original range within the input source that's been prettied.
That information isn't currently available within the AST though, but I could add a range
member to the AST nodes like Babel:
{
"type": "@comment",
"body": "# prettier-ignore",
"start": 3,
"end": 3,
"range": [
46,
64
]
},
@kddeisz Does this sound roughly like the right approach to follow? I'm not quite sure the best way to get the range start/end indexes - other than for scanner events though! 🤔
from plugin-ruby.
I also had a case where I didn't want prettier to format.
it do
expect{ subject.action }.
to change{ subject.some_value } # => this becomes [change do ... end] and it's a SyntaxError
end
So I tried this extension, but it didn't stop the formatting for prettier-ruby.
https://marketplace.visualstudio.com/items?itemName=tombonnike.vscode-status-bar-format-toggle
Can we at least have this extension work with prettier-ruby?
from plugin-ruby.
@kddeisz thanks!
yarn add https://github.com/prettier/plugin-ruby\#master
and restarted vscode, fixed the change do ... end
syntax error.
it do
expect{ subject.action }.
to change{ subject.some_value } # => { ... } doesn't get modified
end
from plugin-ruby.
This is entirely predicated on #370 as that's going to change the way we do comments, just to link the two.
from plugin-ruby.
I'm going to close this as it's now entirely subsumed by #370
from plugin-ruby.
Did #370 resolve the case with # prettier-ignore
? It seems to me that one still can't use # prettier-ignore
to stop autoformatting in cases where the user for some reason wants to disable auto-formatting.
from plugin-ruby.
Wow thank you, you rock! We are thrilled to be able to use Prettier also for Ruby, it is so good and fast and let's me write horrible one-liners that turn into solid Ruby code 😄
from plugin-ruby.
Related Issues (20)
- 4.0 fails on large array of hashes
- No parser could be inferred for file xyz.rb HOT 2
- HAML Formatting with long line HOT 1
- plugin going wrong in testing environment HOT 1
- unfriendly when use API prettier.format HOT 1
- Failed to get connection options from parse server in time HOT 1
- plugin-ruby does not support tab indentation HOT 4
- Change defaultOption.trailingComma to "all" to match Prettier for better diffs and easier code manipulation HOT 3
- Couldn't resolve parser "ruby" HOT 1
- Require blank line between function definitions HOT 1
- Prettier stopped working for Ruby files in VSCode HOT 8
- Any way to force prettier to use the plugin-ruby parser? HOT 1
- Can't run plugin HOT 1
- New release HOT 2
- Formatting is failing for certain files after #1407 HOT 2
- Change in method call chaining style
- Non-stable formatting with a multi-line comment in a method chain
- Weird chained method call block indent
- Option to keep curly braces HOT 1
- Error: undefined method `value' for :call:Symbol HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugin-ruby.