question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New: ability to only lint for certain parts of the code block

See original GitHub issue

Ref https://github.com/airbnb/javascript/issues/685

Not sure how this would work but an example would be in airbnb’s style guide.

3.1 Use the literal syntax for object creation. eslint rules: no-new-object.

// bad
const item = new Object();

// good
const item = {};

So in this case you would want to check the // good part is linted correctly while the // bad snippet is incorrect.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:35 (25 by maintainers)

github_iconTop GitHub Comments

3reactions
btmillscommented, Jul 5, 2016

I just added HTML comments preceding code blocks in the ESLint rule docs, and our new renderer is preserving the comments correctly! I also ran a test with the parser in this plugin. As long as there’s still a blank line preceding the code block (this is required by spec anyway), it correctly picks up the raw HTML and the code block separately.

  • <!--eslint-plugin-markdown ignore-->
  • <!--eslint-disable-block-->
  • <!--eslint-disable--> / <!--eslint-enable-->
  • <!--eslint-plugin-markdown-disable--> / <!--eslint-plugin-markdown-enable-->

Brainstorming a few different options there. Any preferences/other ideas?

1reaction
btmillscommented, Jul 13, 2016

Below, I’ve borrowed from ESLint’s eqeqeq docs and inserted comments to demonstrate what this should look like given the latest proposal. Any objections to implementing this as described?

When disabling a specific rule <!--eslint-disable-next-block eqeqeq-->, the plugin will alert for syntax errors and other rules but ignore errors from eqeqeq:

### always

The `"always"` option (default) enforces the use of `===` and `!==` in every situation.

Examples of **incorrect** code for the `"always"` option:

<!--eslint-disable-next-block eqeqeq-->

```js
/*eslint eqeqeq: ["error", "always"]*/

a == b
foo == true
bananas != 1
```

Without any comments, the plugin will report all errors as received from ESLint:

Examples of **correct** code for the `"always"` option:

```js
/*eslint eqeqeq: ["error", "always"]*/

a === b
foo === true
bananas !== 1
```

When disabled for the entire block, the plugin won’t even bother sending the code to ESLint:

Examples of **syntax errors**:

<!--eslint-disable-next-block-->

```js
!@#$%^&*()
```
Read more comments on GitHub >

github_iconTop Results From Across the Web

flake8 disable linter only for a block of code - Stack Overflow
I want to lint the rest of the file, and I cannot put at the end of each fieldx an # noqa: E501...
Read more >
One bite at a time - How to introduce new lint rules in a large ...
Linters such as ESLint or TSLint can help make your code more readable and maintainable, and help you detect errors earlier.
Read more >
A Complete Guide to Linting Go Programs - freshman.tech
Linting is the process of identifying and reporting on patterns found in code, with the aim of improving consistency, and catching bugs ...
Read more >
Linters aren't in your way. They're on your side
While linters can check formatting and adherence to code style and warn you if you're off, formatters go straight ahead and just apply...
Read more >
Introducing Vale, an NLP-powered linter for prose - Medium
Vale is cross-platform (Windows, macOS, and Linux), written in Go ... ability to ignore code blocks and target only certain sections of text ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found