Skip to content

Update ab-testing linting and prettier settings#15742

Merged
cemms1 merged 7 commits intomainfrom
cemms1/ab-testing-configuration
Apr 23, 2026
Merged

Update ab-testing linting and prettier settings#15742
cemms1 merged 7 commits intomainfrom
cemms1/ab-testing-configuration

Conversation

@cemms1
Copy link
Copy Markdown
Contributor

@cemms1 cemms1 commented Apr 22, 2026

What does this change?

  • Adds overall @guardian/ab-testing package to cover linting for the various sub packages of the ab-testing directory

    • Adds eslint.config.mjs and tsconfig.json to the ab-testing root
    • Removes @guardian/eslint and eslint dependencies from ab-testing sub directories
    • Removes @guardian/prettier and prettier dependencies from ab-testing sub directories
  • Updates the ab-testing-ci Github workflow to run general linting and testing checks ahead of the jobs for each sub package

  • Removes .npmrc lines which hoist eslint from within the dotcom-rendering sub directory up to the root level to allow ab-testing to use it

    • Eslint is now explicitly installed in the ab-testing package.json and configured at this level so no need to continue hoisting
  • Tidies up package.json files within ab-testing so that we only install what we need (removes cdk and similar packages from non cdk directory and removes source-map-register as this looks like a mistake)

Why?

A temporary fix was added to the .npmrc file to hoist the eslint package from the inner dotcom-rendering directory to allow the ab-testing directory to use it (#15723)

Prettier is managed from the repository root but eslint is not. So we need to explicitly install and configure eslint within the ab-testing directory and were previously relying on it being magically available at this level.

This PR allows us to remove the temporary addition to the .npmrc file and better control the linting and formatting behaviour of packages within the ab-testing directory as a whole

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

@cemms1 cemms1 added maintenance Departmental tracking: maintenance work, not a fix or a feature labels Apr 22, 2026
@cemms1 cemms1 marked this pull request as ready for review April 22, 2026 17:17
@cemms1 cemms1 requested review from a team as code owners April 22, 2026 17:17
@cemms1 cemms1 added run_chromatic Runs chromatic when label is applied labels Apr 22, 2026
@github-actions github-actions Bot removed the run_chromatic Runs chromatic when label is applied label Apr 22, 2026
@cemms1 cemms1 force-pushed the cemms1/ab-testing-configuration branch from c3765da to e95f362 Compare April 23, 2026 09:48
@GHaberis
Copy link
Copy Markdown
Contributor

Moving the eslint configuration into the @guardian/ab-testing root and removing separate config in each of the sub-directories is much tidier! 👍

I have a question regarding Prettier. Previously in .github/workflows/ab-testing-ci.yml we had a command run: pnpm prettier:check (running prettier on the ab-testing/config directory?), now we've removed this command (https://github.com/guardian/dotcom-rendering/pull/15742/changes#diff-bf59eaa5e921802f878da128f11ba31ac788bbb910d6b6fbe294ca8ea9a4c6d2L36) is Prettier run as part of CI workflows?

Another question, we've removed the lint-staged step for all sub-directories in /ab-testing, and removed the corresponding rule from the repo's root package.json: https://github.com/guardian/dotcom-rendering/pull/15742/changes#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L18. From what I understand this would have previously run the lint-staged scripts on files that were staged for commit in those directories - by removing this do we no longer run lint checks on files staged for commit in /ab-testing or is this achieved some other way?

@cemms1
Copy link
Copy Markdown
Contributor Author

cemms1 commented Apr 23, 2026

@GHaberis

I have a question regarding Prettier. Previously in .github/workflows/ab-testing-ci.yml we had a command run: pnpm prettier:check (running prettier on the ab-testing/config directory?), now we've removed this command (https://github.com/guardian/dotcom-rendering/pull/15742/changes#diff-bf59eaa5e921802f878da128f11ba31ac788bbb910d6b6fbe294ca8ea9a4c6d2L36) is Prettier run as part of CI workflows?

Prettier is only installed at the root level of the repo and is run from there. The prettier commands prettier:check and prettier:write only exist at the top-level package.json file

Prettier is run as part of the DCR CICD workflow at the moment which is run from the root level and not the sub-directory dotcom-rendering level.

I think the repo might need some further adjustments in the future to ensure we check each part at the right level

Another question, we've removed the lint-staged step for all sub-directories in /ab-testing, and removed the corresponding rule from the repo's root package.json: https://github.com/guardian/dotcom-rendering/pull/15742/changes#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L18. From what I understand this would have previously run the lint-staged scripts on files that were staged for commit in those directories - by removing this do we no longer run lint checks on files staged for commit in /ab-testing or is this achieved some other way?

lint-staged is best configured at the repo root, and is configured in this repo here. What it does at the moment is it runs prettier:write at the repo level and also runs separate ab-testing lint-staged commands. Since most of the nested lint-staged commands were running prettier anyway, this is a bit redundant since it's already covered by the top level. The other part of the nested lint-staged commands were running eslint. Since this is now handled at the ab-testing directory and not the sub-directories, we don't really want this to run on each nested directory independently.
DCR only formats on lint-staged. Adding eslint checks as well slows down the push process.
It's worth noting there are some husky hooks configured for pre-commit (runs lint-staged) and pre-push (runs make tsc in DCR repo) which cover most things you would need to check before pushing to origin

It might be that we want to add ab-testing specific items to the husky hooks

@GHaberis
Copy link
Copy Markdown
Contributor

OK I think I understand! So prettier checks will still run on the /ab-testing directory as part of the CI steps, via the root level prettier:check command, triggered by the Prettier workflow.

Following this PR lint-stage will be configured at root level only, and will run prettier:write on files staged for commit, including the /ab-testing directory. We don’t want to run eslint checks as well as this will slow down the push process - I can see we never triggered eslint checks on the /ab-testing sub-directories so we’re not losing anything.

Copy link
Copy Markdown
Contributor

@GHaberis GHaberis left a comment

Choose a reason for hiding this comment

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

Nice work 👍

@cemms1 cemms1 force-pushed the cemms1/ab-testing-configuration branch from e95f362 to 235b1f0 Compare April 23, 2026 14:03
@cemms1 cemms1 added the run_chromatic Runs chromatic when label is applied label Apr 23, 2026
@github-actions github-actions Bot removed the run_chromatic Runs chromatic when label is applied label Apr 23, 2026
@cemms1 cemms1 merged commit 79c2dbc into main Apr 23, 2026
32 checks passed
@cemms1 cemms1 deleted the cemms1/ab-testing-configuration branch April 23, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Departmental tracking: maintenance work, not a fix or a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants