Skip to content

Commit

Permalink
feat: move eslint --init to @eslint/create-config
Browse files Browse the repository at this point in the history
fixes eslint#14768, fixes eslint#15159

Update: rm eslint auto config

refs: https://github.com/aladdin-add/rfcs/blob/bdc12aa062750d837e5a3bbbf2f6e5e3a98da388/designs/2021-init-command-eslint-cli/README.md#1-remove-eslint-auto-config

Update: mv eslint --init to another package

moved `lib/init/config-rule` to tools, as it is also used by some others

refs: https://github.com/aladdin-add/rfcs/blob/bdc12aa062750d837e5a3bbbf2f6e5e3a98da388/designs/2021-init-command-eslint-cli/README.md#2-move-eslint---init-related-files-to-a-separate-repo

chore: fix imports to make test passing

todo: use the new eslint api

fix: use the new eslint api (async)

fix: remove espree from deps

chore: fix a failing test

fix: a failing test

chore: cleanup TODOs

fix: allow to use local-installed eslint

wip: fix one-var

chore: lib => esm

chore: tests => esm

todo: proxyquire => td

chore: update deps to latest

fix: should write a file through fs when a ${fileType} path is passed

replaced proxyquire & sinon => td

fix: should include a newline character at EOF

chore: add testdouble

--wip-- [skip ci]

chore: remove package @eslint/create-eslint

feat: update npm --init to run `npm init @eslint/config`

docs: update getting-started

Update README.md

Update getting-started.md

chore: rm init fixtures

fix: `npm init @eslint/config` output

chore: rm unused files

chore: rm unused deps

Update bin/eslint.js

Co-authored-by: Brandon Mills <btmills@users.noreply.github.com>

chore: fix typo
  • Loading branch information
aladdin-add committed Dec 20, 2021
1 parent 9d951ac commit 45c23f9
Show file tree
Hide file tree
Showing 25 changed files with 18 additions and 3,443 deletions.
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
8 changes: 4 additions & 4 deletions docs/user-guide/getting-started.md
Expand Up @@ -23,14 +23,14 @@ 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:

```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

1 comment on commit 45c23f9

@m0dul3
Copy link

@m0dul3 m0dul3 commented on 45c23f9 Dec 27, 2021

Choose a reason for hiding this comment

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

#1

Please sign in to comment.