# Trouble with eslint

**URL:** https://meta.discourse.org/t/trouble-with-eslint/318178
**Category:** Development
**Created:** [July 24, 2024, 5:54pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178 "2024-07-24T17:54:05Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 24, 2024, 5:54pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178/1 "2024-07-24T17:54:06Z")

</div>

I’ve got a new plugin that’s failing lint tests:

```plaintext
Run if test -f .prettierrc.cjs; then
yarn run v1.22.22
$ /home/runner/work/discourse-multi-rating/discourse-multi-rating/node_modules/.bin/eslint --ext .js,.gjs,.js.es6 --no-error-on-unmatched-pattern test/javascripts assets/javascripts admin/assets/javascripts
Invalid option '--ext' - perhaps you meant '-c'?
You're using eslint.config.js, some command line flags are no longer available. Please see https://eslint.org/docs/latest/use/command-line-interface for details.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 2.

```

I don’t see `--ext` in my source tree, so maybe it’s in `@discourse/lint-configs/eslint")`? I don’t know where to find that.

I can’t see what I’m doing wrong or how this isn’t affecting a whole bunch of plugins. 🤷

---

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [July 24, 2024, 9:24pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178/2 "2024-07-24T21:24:58Z")

</div>

I’ve seen this error on my own plugin. I figured out it was because I tried to update the eslint config file from `.eslintrc.cjs` to the latest flat config format `eslint.config.js` via the eslint migration. `eslint.config.js` doesn’t support the `--ext` ([Command Line Interface Reference - ESLint - Pluggable JavaScript Linter](https://eslint.org/docs/latest/use/command-line-interface#--ext)), so changing the file to the older `.eslintrc.cjs` should fix it.

There are some extra instructions on how to setup the lint files in [lint-configs/lint-configs at main · discourse/lint-configs · GitHub](https://github.com/discourse/lint-configs/tree/main/lint-configs)

For some extra context, @discourse/lint-configs use eslint 8.57.0, which by default doesn’t utilize the new flat config [https://eslint.org/docs/v8.x/use/configure/configuration-files#configuration-file-formats](https://eslint.org/docs/v8.x/use/configure/configuration-files#configuration-file-formats).

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2024, 6:30pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178/3 "2024-07-26T18:30:56Z")

</div>

> [@Alteras](#):
>
> I figured out it was because I tried to update the eslint config file from `.eslintrc.cjs` to the latest flat config format `eslint.config.js` via the eslint migration.

That’s what’s so strange. I don’t see a `eslint.confi.js` anywhere on my filesystem (if I’m to trust `locate`, and certainly not in my source tree).

Did you get it to work?

---

<div class="post-metadata">

### Author: ![Alteras](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alteras/32/179824_2.png) [@Alteras](https://meta.discourse.org/u/Alteras)
#### Post date: [July 26, 2024, 6:45pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178/4 "2024-07-26T18:45:08Z")

</div>

Oh that’s weird… Yes, I was able to get mine to work.

I would check the package.json to see if the devDependencies has `"eslint": "8.57.0",` and not a 9.x.x

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2024, 6:47pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178/5 "2024-07-26T18:47:41Z")

</div>

> [@Alteras](#):
>
> I would check the package.json

Yes. 😿 I just noticed that eslint and prettier were changed in `package.json`. I swear it was just a minute ago that I cloned it from the skeleton. 🤷

Now it’s giving me (legit) errors at github, but I can’t get estlint to run locally to be able to get it to fix stuff.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [July 26, 2024, 7:31pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178/6 "2024-07-26T19:31:09Z")

</div>

Jay,

do:

```plaintext
yarn

```

then

```plaintext
yarn eslint --fix plugins/<my-plugin>

```

(obviously update “my plugin”)

both from `discourse` directory

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 26, 2024, 7:42pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178/7 "2024-07-26T19:42:43Z")

</div>

OMG. I’d just managed to fix it in some way that was completely impossible to reproduce, so this is a lifesaver. And now I’ve added it to my magic file so this might work next time

```bash
if [["$ARG" == 'fix-eslint']]
then
  cd ~/src/discourse-repos/discourse
  yarn
  for x in ~/plugins/* 
  do
    yarn eslint --fix x
  done
fi

```

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [July 30, 2024, 3:25pm UTC](https://meta.discourse.org/t/trouble-with-eslint/318178/8 "2024-07-30T15:25:39Z")

</div>

> [@merefield](#):
>
> (obviously update “my plugin”)

Wait. Are you saying that this will update `eslint` to the proper version? Or run `eslint`? Or that if I run it that way, it’ll be the right version?
