🙅‍♀️ Ignoring code

👋 FYI, this note is over 6 months old. Some of the content may be out of date.
On this page

ESlint Jump to heading

https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments

/* eslint-disable */
alert('foo')
/* eslint-enable */

/* eslint-disable no-alert, no-console */
alert('foo')
console.log('bar')
/* eslint-enable no-alert, no-console */

alert('foo') // eslint-disable-line

alert('foo') // eslint-disable-line no-alert

Prettier Jump to heading

https://prettier.io/docs/en/ignore.html

JavaScript Jump to heading

A JavaScript comment of // prettier-ignore will exclude the next node in the abstract syntax tree from formatting.

// prettier-ignore
matrix(
1, 0, 0,
0, 1, 0,
0, 0, 1
)

HTML Jump to heading

<!-- prettier-ignore -->
<div class="x" >hello world</div >

<!-- prettier-ignore-attribute -->
<div
(mousedown)=" onStart ( ) "
(mouseup)=" onEnd ( ) "
>
</div>

<!-- prettier-ignore-attribute (mouseup) -->
<div
(mousedown)="onStart()"
(mouseup)=" onEnd ( ) "
>
</div>

JSX Jump to heading

<div>
{/* prettier-ignore */}
<span ugly format='' />
</div>

CSS Jump to heading

/* prettier-ignore */
.my ugly rule
{

}

Markdown Jump to heading

<!-- prettier-ignore -->
Do not format this

This type of ignore is only allowed to be used in top-level and aimed to disable formatting for auto-generated content, e.g. all-contributors, markdown-toc, etc.

<!-- prettier-ignore-start -->
<!-- SOMETHING AUTO-GENERATED BY TOOLS - START -->

| MY | AWESOME | AUTO-GENERATED | TABLE |
|-|-|-|-|
| a | b | c | d |

<!-- SOMETHING AUTO-GENERATED BY TOOLS - END -->
<!-- prettier-ignore-end -->

YAML Jump to heading

# prettier-ignore
key : value
hello: world

GraphQL Jump to heading

{
# prettier-ignore
addReaction(input:{superLongInputFieldName:"MDU6SXNzdWUyMzEzOTE1NTE=",content:HOORAY}) {
reaction {content}
}
}

TypeScript Jump to heading

// @ts-ignore

TSLint Jump to heading

/* tslint:disable no-console */
console.log()
/* tslint:disable no-console */

/* tslint:disable */
/* tslint:enable */

/* tslint:disable:rule */
/* tslint:enable:rule */

/* tslint:disable-next-line */
/* tslint:disable-line */
/* tslint:disable-next-line:rule */

Stylelint Jump to heading

/* stylelint-disable */
const Container = styled.div``
/* stylelint-enable */

← Back home