jednano / eclint

Validate or fix code that doesn't adhere to EditorConfig settings or infer settings from existing code.
MIT License
307 stars 28 forks source link

Support block comments defined only via start and end #85

Closed silverwind closed 7 years ago

silverwind commented 7 years ago

For example, block comments in CSS:

/* block
   comment */

This fails to pass with these options:

[*.css]
block_comment_start = /*
block_comment_end = */

Another issue with above block is that it fails the indent_size rule when it is set to 2 or 4, while I think it should be accepted. I'd suggest to disable indent_size checks inside block comments.

gucong3000 commented 7 years ago
/**
 * block
 * comment
 */

We only support C-style documentation comments.

silverwind commented 7 years ago

These extra * are purely stylistic and should be ignored when linting, they are not mandatory in C either.

gucong3000 commented 7 years ago

Whould you like to try this PR #87 and do some test? You can install from npm i jedmao/eclint#non_doc_block_comments

gucong3000 commented 7 years ago

@silverwind The new release destroys some pipeline of projects. I plan to not support for this format in eclint.fix(), just support it in eclint.check().

96

gucong3000 commented 7 years ago

There is format that we support for fix:

/*
if(true) {
    //
}
*/

// #if _DEBUG
const data = {
  key: 'value'
};
/* #else
const data = {
  key: 'value'
};
// #endif */

/*
 * module name
 */

If you have any way to compatible all of these formats, please submit PRs

silverwind commented 7 years ago

Why not keep it simple and ignore indentation in block comments completely (both in fix and check)? You can't really guess what kind of comment style a user uses, unless EditorConfig has an option for it.

gucong3000 commented 7 years ago

As far as I know, eclint is the only linter that supports comments. lintspaces is compatible with .editorconfig, and it have a option to ignore indentation in comments. Does users need two tools with same features?

gucong3000 commented 7 years ago

Why not keep it simple and ignore indentation in block comments.

Because this feature (comment supports) worked well in each project I was involved in. And I need it.

gucong3000 commented 7 years ago
/*
 * block
 * comment
 */

Do you hate this comment style? It is support by many IDE and editor.

silverwind commented 7 years ago

It might be a good idea to add/parse an option in .editorconfig for block comment indentation style.

silverwind commented 7 years ago

And no, I don't hate your style, but I see it as extra typing work that can be avoided. ;)

gucong3000 commented 7 years ago

It might be a good idea to add/parse an option

What is this options look like?

silverwind commented 7 years ago

I guess it could use names for the styles, like indent_brace_style does, but in the simple case, a value of aligned for your style, and any other value for ignoring indentation would be fine I guess.

You could add support for more styles later. The option could be called block_comment_indent_style.

gucong3000 commented 7 years ago

we should open a new issue for editorconfig/editorconfig

gucong3000 commented 7 years ago

I think stylelint is mach better than eclint for CSS file

silverwind commented 7 years ago

Yeah, I actually use both :)