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

feat: move eslint --init to @eslint/create-config #15150

Merged
merged 5 commits into from Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -54,7 +54,7 @@ $ npm install eslint --save-dev
You should then set up a configuration file:

```sh
$ ./node_modules/.bin/eslint --init
$ npm init @eslint/config
```

After that, you can run ESLint on any file or directory like this:
Expand All @@ -65,7 +65,7 @@ $ ./node_modules/.bin/eslint yourfile.js

## <a name="configuration"></a>Configuration

After running `eslint --init`, you'll have a `.eslintrc` file in your directory. In it, you'll see some rules configured like this:
After running `npm init @eslint/config`, you'll have a `.eslintrc` file in your directory. In it, you'll see some rules configured like this:

```json
{
Expand Down
8 changes: 7 additions & 1 deletion bin/eslint.js
Expand Up @@ -124,7 +124,13 @@ ${message}`);

// Call the config initializer if `--init` is present.
if (process.argv.includes("--init")) {
await require("../lib/init/config-initializer").initializeConfig();

// `eslint --init` has been moved to `@eslint/create-config`
console.warn("You can also run this command directly using 'npm init @eslint/config'.");

const spawn = require("cross-spawn");

spawn.sync("npm", ["init", "@eslint/config"], { encoding: "utf8", stdio: "inherit" });
return;
}

Expand Down
1 change: 0 additions & 1 deletion docs/developer-guide/architecture.md
Expand Up @@ -7,7 +7,6 @@ At a high level, there are a few key parts to ESLint:
* `bin/eslint.js` - this is the file that actually gets executed with the command line utility. It's a dumb wrapper that does nothing more than bootstrap ESLint, passing the command line arguments to `cli`. This is intentionally small so as not to require heavy testing.
* `lib/api.js` - this is the entry point of `require("eslint")`. This file exposes an object that contains public classes `Linter`, `ESLint`, `RuleTester`, and `SourceCode`.
* `lib/cli.js` - this is the heart of the ESLint CLI. It takes an array of arguments and then uses `eslint` to execute the commands. By keeping this as a separate utility, it allows others to effectively call ESLint from within another Node.js program as if it were done on the command line. The main call is `cli.execute()`. This is also the part that does all the file reading, directory traversing, input, and output.
* `lib/init/` - this module contains `--init` functionality that set up a configuration file for end users.
* `lib/cli-engine/` - this module is `CLIEngine` class that finds source code files and configuration files then does code verifying with the `Linter` class. This includes the loading logic of configuration files, parsers, plugins, and formatters.
* `lib/linter/` - this module is the core `Linter` class that does code verifying based on configuration options. This file does no file I/O and does not interact with the `console` at all. For other Node.js programs that have JavaScript text to verify, they would be able to use this interface directly.
* `lib/rule-tester/` - this module is `RuleTester` class that is a wrapper around Mocha so that rules can be unit tested. This class lets us write consistently formatted tests for each rule that is implemented and be confident that each of the rules work. The RuleTester interface was modeled after Mocha and works with Mocha's global testing methods. RuleTester can also be modified to work with other testing frameworks.
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/command-line-interface.md
Expand Up @@ -457,7 +457,7 @@ Example:

#### `--init`

This option will start config initialization wizard. It's designed to help new users quickly create .eslintrc file by answering a few questions, choosing a popular style guide, or inspecting your source files and attempting to automatically generate a suitable configuration.
This option will run `npm init @eslint/config` to start config initialization wizard. It's designed to help new users quickly create .eslintrc file by answering a few questions, choosing a popular style guide.

The resulting configuration file will be created in the current directory.

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/configuring/configuration-files.md
Expand Up @@ -232,7 +232,7 @@ A [sharable configuration](https://eslint.org/docs/developer-guide/shareable-con

The `extends` property value can omit the `eslint-config-` prefix of the package name.

The `eslint --init` command can create a configuration so you can extend a popular style guide (for example, `eslint-config-standard`).
The `npm init @eslint/config` command can create a configuration so you can extend a popular style guide (for example, `eslint-config-standard`).

Example of a configuration file in YAML format:

Expand Down
10 changes: 5 additions & 5 deletions docs/user-guide/getting-started.md
Expand Up @@ -20,17 +20,17 @@ npm install eslint --save-dev
yarn add eslint --dev
```

You should then set up a configuration file, and the easiest way to do that is to use the `--init` flag:
You should then set up a configuration file, and the easiest way to do that is:

```sh
$ npx eslint --init
$ npm init @eslint/config

# or

$ yarn run eslint --init
$ yarn create @eslint/config
```

**Note:** `--init` assumes you have a `package.json` file already. If you don't, make sure to run `npm init` or `yarn init` beforehand.
**Note:** `npm init @eslint/config` assumes you have a `package.json` file already. If you don't, make sure to run `npm init` or `yarn init` beforehand.

After that, you can run ESLint on any file or directory like this:

Expand All @@ -48,7 +48,7 @@ It is also possible to install ESLint globally rather than locally (using `npm i

**Note:** If you are coming from a version before 1.0.0 please see the [migration guide](migrating-to-1.0.0.md).

After running `eslint --init`, you'll have a `.eslintrc.{js,yml,json}` file in your directory. In it, you'll see some rules configured like this:
After running `npm init @eslint/config`, you'll have a `.eslintrc.{js,yml,json}` file in your directory. In it, you'll see some rules configured like this:

```json
{
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/migrating-from-jscs.md
Expand Up @@ -42,7 +42,7 @@ $ polyjuice --jscs .jscsrc.json ./foo/.jscsrc.json > .eslintrc.json
If you don't want to convert your JSCS configuration directly into an ESLint configuration, then you can use ESLint's built-in wizard to get you started. Just run:

```sh
$ eslint --init
$ npm init @eslint/config
```

You'll be guided through a series of questions that will help you setup a basic configuration file to get you started.
Expand Down