Skip to content

[FR] option to ignore code blocks by meta string

Open

Description

Hi, we at MDN are considering adopting ESLint for our code examples.

We have got some initial success at fixing thousands of syntax errors / stylistic issues. However, we have some code blocks that intentionally demonstrate bad syntax:

```js example-bad
// You can't use a try...catch without braces
try doSomething();
catch (e) console.error(e);
```

We decided to not use eslint-skip anywhere (or at least as sparsely as possible), so that external contributors don't get confused. On top of that, we don't want to duplicate metadata: since example-bad is already used by the platform to render a code block with a cross, we think the linter should accommodate that convention.

Therefore, I want to propose a feature that ignores code blocks by meta string—currently, the parser takes advantage of glob patterns to differentiate code blocks, so adding a Markdown-specific option could be tricky. I don't have a solid API design on top of my head, but maybe we can add the meta string as part of the language extension (e.g. *.example-bad.js)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Triaging

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions