Closed Bug 1809497 Opened 2 years ago Closed 2 years ago

Separate out prettier and ESLint to run as different processes

Categories

(Developer Infrastructure :: Lint and Formatting, task, P2)

Tracking

(firefox114 fixed)

RESOLVED FIXED
Tracking Status
firefox114 --- fixed

People

(Reporter: standard8, Assigned: standard8)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file, 1 obsolete file)

Running ESLint with prettier integrated as part of it causes several issues:

  • eslint-plugin-html and prettier conflict if prettier is enabled on html files, causing inconsistent formatting.
  • We are unable to run separate formatting only linters (xref bug 1803229).
  • Prettier itself recommends against integrating the two. Quoting:

You end up with a lot of red squiggly lines in your editor, which gets annoying. Prettier is supposed to make you forget about formatting – and not be in your face about it!
They are slower than running Prettier directly.
They’re yet one layer of indirection where things may break.

Hence I think we should work towards separating these. From a configuration perspective it should be reasonably simple, the biggest part will be getting the commands hooked up right so as not to break workflows.

Actually, I think this bug should only separate the config & make ESLint and prettier run as separate commands behind the scenes - so that everything is the same from a developer's perspective.

Bug 1807711 should look at whatever ./mach <command> changes are necessary for what is required there.

One downside here, is that prettier only supports one ignore file (the .prettierignore), and not importing from other files. Something like that would require changes in prettier. That's currently stalled, but maybe we can cope with merging the files for now, and maybe see if we can help that move forward.

Assignee: nobody → standard8
Summary: Separate out prettier and ESLint to different processes → Separate out prettier and ESLint to run as different processes
Depends on: 1825507
Blocks: 1825508
Depends on: 1825715
Depends on: 1825739
Blocks: 1826062
Blocks: 1826063
Depends on: 1826548
Depends on: 1826561
Depends on: 1826768
Attachment #9327328 - Attachment description: Bug 1809497 - Separate running of Prettier from ESLint completely. → Bug 1809497 - Separate running of Prettier from ESLint completely. r?#linter-reviewers!
Pushed by mbanner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/42c2bba671df Separate running of Prettier from ESLint completely. r=linter-reviewers,devtools-reviewers,andi
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED

It seems now if I try to use await in a non-async function I get an error message from prettier: SyntaxError: Unexpected token, expected ";"
IIRC earlier it told you pretty clearly "await can only be used in async functions" or something like this.

Are they run in the right order? Or are there ways to improve this?

(In reply to Magnus Melin [:mkmelin] from comment #8)

It seems now if I try to use await in a non-async function I get an error message from prettier: SyntaxError: Unexpected token, expected ";"
IIRC earlier it told you pretty clearly "await can only be used in async functions" or something like this.

Are they run in the right order? Or are there ways to improve this?

ESlint is always run before Prettier when run via ./mach lint.

My guess would be that you're running Prettier on the file, but not ESLint. Maybe it is ignored in comm-central's .eslintignore but hasn't been added to .prettierignore? One of the later follow-ups is to fix that duplication (bug 1825508).

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: