Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Core concepts page #16399

Merged
merged 12 commits into from Oct 21, 2022
2 changes: 1 addition & 1 deletion docs/src/pages/rules.md
Expand Up @@ -6,7 +6,7 @@ eleventyNavigation:
key: rules
parent: user guide
title: Rules
order: 4
order: 5
---

{% from 'components/rule-categories.macro.html' import ruleCategories, recommended, fixable, hasSuggestions %}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/user-guide/command-line-interface.md
Expand Up @@ -5,7 +5,7 @@ eleventyNavigation:
key: command line interface
parent: user guide
title: Command Line Interface
order: 3
order: 4

---

Expand Down
2 changes: 1 addition & 1 deletion docs/src/user-guide/configuring/index.md
Expand Up @@ -5,7 +5,7 @@ eleventyNavigation:
key: configuring
parent: user guide
title: Configuring
order: 2
order: 3

---

Expand Down
86 changes: 86 additions & 0 deletions docs/src/user-guide/core-concepts.md
@@ -0,0 +1,86 @@
---
title: Core Concepts
layout: doc
eleventyNavigation:
key: core concepts
title: Core Concepts
parent: user guide
order: 2
---

This page contains a high-level overview of some of the core concepts of ESLint.

## What is ESLint?

ESLint is a configurable JavaScript linter. It's like spell check and autocorrect
bpmutter marked this conversation as resolved.
Show resolved Hide resolved
for your JavaScript code. It helps you write JavaScript in a consistent style
and fix bugs in your code.

## Rules

Rules are the core building block of ESLint. A rule validates if your code meets a
certain expectation, and what to do if it does not meet that expectation.
Rules can also contain additional configuration options specific to that rule.

For example, the [`semi` rule](../rules/semi.md`) lets you specify whether or not
bpmutter marked this conversation as resolved.
Show resolved Hide resolved
JavaScript statements should end with a semicolon (`;`).
You can set the rule to either always require semicolons or require that
a statement never ends with a semicolon.

ESLint contains hundreds of built-in rules that you can use.
You can also create custom rules or use rules that others have
created with [plugins](#plugins).

For more information, refer to [Rules](../rules/).

## Configuration Files

An ESLint configuration file is a single place where you put all the configuration
bpmutter marked this conversation as resolved.
Show resolved Hide resolved
for ESLint your project. You can include built-in rules, how you want them enforced,
plugins with custom rules, which files you want rules to apply to, and more.

For more information, refer to [Configuration Files](./configuring/configuration-files.md).
bpmutter marked this conversation as resolved.
Show resolved Hide resolved

## Plugins

An ESLint plugin is an npm module that contains a set of ESLint rules.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugins can contain rules, configurations, processors, and environments.

Plugins can be used to enforce a style guide and support JavaScript extensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically shareable configs are used to enforce style guides using built-in rules while plugins provide additional rules.

A popular common use case is to enforce best practices for a given framework (React, Vue, and Angular all use ESLint plugins to provide rules specific to how best to use those frameworks).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, will update accordingly

(like TypeScript) or frameworks (like React).
You can add single rules or sets of rules from a plugin.
Often plugins come with recommended sets of rules that you can include in your project.

For more information, refer to [Configuring Plugins](./configuring/plugins.md).

## Formatters

An ESLint formatter controls the appearance of the linting results.
If you're using a code editor with an ESLint integration to see linting results
in line, the editor is using an ESLint formatter to display those results.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline messages, such as those in the VS Code editor, don't use formatters.

Formatters are solely for use with the command line interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks for clarifying. what are some reasons you might want to use a formatter?

for example, why would i want to output my results to HTML?


For more information, refer to [Formatters](./formatters/index.md).

## Integrations

One of the things that makes ESLint such a useful tool is the ecosystem of integrations
that surrounds. These integrations extend the core functionality of ESLint.
bpmutter marked this conversation as resolved.
Show resolved Hide resolved
For example, many code editors have ESLint extensions that show you the ESLint results
of your code in the file as you work so that you don't need to use the ESLint CLI
to see linting results.

For more information, refer to [Integrations](./integrations.md).
bpmutter marked this conversation as resolved.
Show resolved Hide resolved
For a curated collection of popular ESLint integrations,
see the [awesome-eslint Github repository](https://github.com/dustinspecker/awesome-eslint).
bpmutter marked this conversation as resolved.
Show resolved Hide resolved

## CLI & Node.js API

The ESLint CLI is a command line interface that lets you execute linting
from the terminal. The CLI has a variety of options that you can pass to its commands.

The ESLint Node.js API lets you use ESLint programmatically from Node.js code.
The API is useful when developing plugins, integrations, and other tools related
to ESLint.

Unless you are extending ESLint in some way, you should use the CLI.

For more information, refer to [Command Line Interface](./command-line-interface.md)
bpmutter marked this conversation as resolved.
Show resolved Hide resolved
and [Node.js API](../developer-guide/nodejs-api.md).
bpmutter marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions docs/src/user-guide/formatters/index.md
Expand Up @@ -5,7 +5,7 @@ eleventyNavigation:
key: formatters
parent: user guide
title: Formatters
order: 5
order: 6
edit_link: https://github.com/eslint/eslint/edit/main/templates/formatter-examples.md.ejs
---

Expand Down Expand Up @@ -43,7 +43,7 @@ function addOne(i) {
};
```

### `.eslintrc`:
### `.eslintrc`

```json
{
Expand Down
2 changes: 1 addition & 1 deletion docs/src/user-guide/integrations.md
Expand Up @@ -5,7 +5,7 @@ eleventyNavigation:
key: integrations
parent: user guide
title: Integrations
order: 6
order: 7

---

Expand Down
2 changes: 1 addition & 1 deletion docs/src/user-guide/migrating-to-8.0.0.md
Expand Up @@ -5,7 +5,7 @@ eleventyNavigation:
key: migrating to v8
parent: user guide
title: Migrating to v8.x
order: 6
order: 7

---

Expand Down