SoftwareMarbles / lazy

Hackable Coding Assistant
http://getlazy.org
MIT License
1 stars 0 forks source link

Add lazy pragma that engines know how to translate #22

Closed ierceg closed 7 years ago

ierceg commented 7 years ago

Currently users have to know the underlying engine implementation to correctly define their pragmas but shouldn't they be able to define them on lazy level and then have lazy (that is, its underlying engines) figure out the desired outcome no matter the details?

For example in some engines we have to turn off class-method-use-this warning with:

/* eslint class-methods-use-this: off */

This should really be expressed as (made up, changed pragma name to show that there is no 1:1 mapping):

/* lazy class-methods-must-use-this: off */
ierceg commented 7 years ago

@neboysa you didn't even let me know that this was done! But now I have a request (of course! ;) Can we make this work:

// lazy ignore rule1 rule2 rule3 ; and comments still work as well!

instead of specifying each rule on a separate line. We could even use a different syntax, more in line with standard C/C++ pragmas (e.g. // #lazy ignore(rule1, rule2, rule3) and now whatever I write here is ignored) or simply split the rule params with space (.split(' ')) and ignore everything after the first one starts with ; or the last one that contains ;

ierceg commented 7 years ago

What I like about the implementation is that it's not related to any particular engine - anything that returns ruleId will work. But the style of comments is tightly coupled to the style of comments used in a language, right? So in YAML we can't specify # lazy ignore whatever and expect it to work, right? That needs fixing. We need a "comments linter" engine anyway and that one will have to figure out the comments from all the different languages so there is a core reusable component there.

neboysa commented 7 years ago

You can also write:

// lazy ignore-once ruleId

and rule will be ignored just once (on first occurrence after the above directive).

neboysa commented 7 years ago

I vote for following syntax:

// lazy ignore rule1 rule2 rule3 ; this is not analyzed

Its kind of sexy & simple...

?

neboysa commented 7 years ago

@ierceg I am not sure I understand this about comments being tightly coupled to the style of comments in a language...

Right now, directives can be in one of these forms:

// lazy ignore rule
/* lazy ignore rule */
# lazy ignore rule

So, we are supporting C-style (// /* */) and YAML style (#) comments.

Plus a hack: for example in HTML file (that doesn't support any of these comment styles) you can write:

<!-- // lazy ignore rule -->
ierceg commented 7 years ago

That -once thing is just great!

Re tightly coupled, that's what I meant: different languages have different ways of creating comments but /* */, // and # seem to cover 95+% (no old Pascal comments though ;)

So let's just do multi-rule syntax as you proposed.

ierceg commented 7 years ago

This has been solved I think @neboysa ?

neboysa commented 7 years ago

Yep. Resolved.

Sent from my ZX Spectrum.

On Mon, Jan 16, 2017 at 7:12 PM +0100, "Ivan Erceg" notifications@github.com wrote:

This has been solved I think @neboysa ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.