prettier eslint plugin reports bogus errors for contrib projects

Created on 10 October 2022, about 2 years ago
Updated 6 May 2023, over 1 year ago

Problem/Motivation

core/.prettierignore and core/.prettierrc.json are not used when eslint runs in a contrib project directory, as they are not in a parent path. As a result, "prettier" eslint plugin runs in an unconfigured state, and reports bogus errors, e.g. single quotes should be changed to double quotes in .yml files: error Replace `''` with `""` prettier/prettier

Steps to reproduce

Run CI for a contrib project, or manually: yarn install dependencies for core, and from a contrib project directory run ../../../core/node_modules/.bin/eslint --resolve-plugins-relative-to=../../../core .

Proposed resolution

There is already a top-level .eslintrc.json file which extends the core/.eslintrc.json file, but I don't think there's a way for a top-level .prettierrc.json to extend core/.prettierrc.json as well.

It'd be possible for drupal-core to copy the prettier config into its top-level .eslintrc.json, that way eslint would function correctly when run by contrib developers. This means there would be some redundant configuration; also is not officially recommended in case there are any prettier plugins installed that just read .prettierrc.json - see https://github.com/prettier/eslint-plugin-prettier#options

Maybe testbot could symlink core/.prettierrc.json into its parent directory? That way these configs would be in a parent directory of the directory being linted.

Note however that core/.prettierrc.json enforces ES6 javascript via the "trailingComma": "all" rule. It might be too soon to do that for any contrib projects that want to maintain IE11 support, in which case separate contrib rules with "trailingComma": "es5" should be used - see also a specific followup about this: #3314595: Core eslint forces ES6 in contrib projects β†’ .

Remaining tasks

Implement a fix and review.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Component

Testrunner Codebase

Created by

πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024