It would be helpful to show examples of correct, incorrect code for each linter configuration scenario.
Agreed that this would be a good idea @m5rk! We could add examples to the metadata that each rule has. Another easier method would be to somehow use the test code to generate the examples. However, good test cases and good code examples aren't perfectly overlapping sets, so I'm not sure if this would be possible.
How does ESLint current implementation is? They have this feature.
eslint does not do anything special in oder to generate examples, they just wrote then dow for each markdown rule definition. See https://raw.githubusercontent.com/eslint/eslint.github.io/master/docs/rules/array-bracket-newline.md .
I think this project really needs this. I've working to update rules along this week and it has been a pain to which rule match with the error displayed in the console and also sometimes is not that obvious how to fix it, specially for beginners.
This is how in eslint is being displayed
```js
/xxx/xxx/xxx/src/myComponent.js
13:41 error Missing semicolon semi
````
http://eslint.org/docs/rules/semi
I think the procedure for tslint should be similar approach. I know they have some kinda fancy plugins (algolia, kramdown), but, at least display some basic example should be a problem.
~This is the current approach (the second issue is hard to match with some rule if you are not familiar with all rules)~
``bash
ERROR: src/myComponent.tsx[111, 6]: Unnecessary semicolon
ERROR: src/myComponent.tsx[2, 1]: Import sources within a group must be alphabetized
````
โ ๏ธ This can be addressed via formats eg:eg: tslint -f codeFrame`
~It should looks like this at least~
```bash
ERROR: src/myComponent.tsx[111, 6]: Unnecessary semicolon [semicolon]
ERROR: src/myComponent.tsx[2, 1]: Import sources within a group must be alphabetized [ordered-imports].
````
I'm open to help.
Your point about the formatters is fair - I think the default formatter should display the rule name. This would be a breaking change though, so would have to be reserved for a major version bump.
@JKillian I think the formatters is done already eg: (tslint -f codeFrame), the formatter display correctly the rule that violate the code style established in your tslint.conf. The next point was lack of examples for each rule in the main website.
One easy enhancement here would be to hyperlink to the test files hosted on Github for each rule. Our test markup syntax makes them almost as readable as code examples and these are guaranteed to be kept up to date (unlike static documentation).
I'm learning about Jekyll now, but perhaps someone can save me some time--can Jekyll handle optional metadata props? Not even 50% of the rules need this kind of documentation, in my opinion. Is it possible to add this documentation incrementally? To a select group of rules now, more in future?
โ ๏ธ TSLint's time has come! โ ๏ธ
TSLint is no longer accepting most feature requests per #4534. See typescript-eslint.io for the new, shiny way to lint your TypeScript code with ESLint. โจ
It was a pleasure open sourcing with you all!
๐ค Beep boop! ๐ TSLint is deprecated ๐ _(#4534)_ and you should switch to typescript-eslint! ๐ค
๐ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐
Most helpful comment
eslintdoes not do anything special in oder to generate examples, they just wrote then dow for each markdown rule definition. See https://raw.githubusercontent.com/eslint/eslint.github.io/master/docs/rules/array-bracket-newline.md .I think this project really needs this. I've working to update rules along this week and it has been a pain to which rule match with the error displayed in the console and also sometimes is not that obvious how to fix it, specially for beginners.
This is how in eslint is being displayed
```js
/xxx/xxx/xxx/src/myComponent.js
13:41 error Missing semicolon semi
````
http://eslint.org/docs/rules/semi
I think the procedure for
tslintshould be similar approach. I know they have some kinda fancy plugins (algolia, kramdown), but, at least display some basic example should be a problem.~This is the current approach (the second issue is hard to match with some rule if you are not familiar with all rules)~
``
bash ERROR: src/myComponent.tsx[111, 6]: Unnecessary semicolon ERROR: src/myComponent.tsx[2, 1]: Import sources within a group must be alphabetized ```` โ ๏ธ This can be addressed via formats eg:eg: tslint -f codeFrame`~It should looks like this at least~
```bash
ERROR: src/myComponent.tsx[111, 6]: Unnecessary semicolon [semicolon]
ERROR: src/myComponent.tsx[2, 1]: Import sources within a group must be alphabetized [ordered-imports].
````
I'm open to help.