ESLint configuration change for test directories

Skip to first unread message

Mark Banner

Aug 4, 2022, 4:13:38 AM (12 days ago) Aug 4
to, firefox-dev list

I have just landed a change to how we handle the configuration of test directories for ESLint.

The big change is that all test directories which need manual ESLint configuration assignment are now listed in the top-level file .eslintrc-test-paths.js. Previously, these would need individual .eslintrc.js files within the test directories.

The documentation on source docs has been updated.

Please note:

  • When adding new test directories, please try and conform to one of the formats listed at the start of .eslintrc-test-paths.js
    • This will mean you do not need to add your directory to .eslintrc-test-paths.js.
  • Do not add new cases where there are test directories with multiple types of tests in the same directory.
    • ESLint will now throw a failure in this case.
    • We do this because ESLint cannot easily handle multiple test types in one directory, and attempting to do so may cause rules to be applied to incorrect test types, as well as false-positives for availability of globals.

We've made this change because the previous way causes issues when rolling out new rules for tests. If the test configuration enables a new rule, but we want to disable it for some test directories (e.g. incremental roll-out), the fact the test configuration was applied in the sub-directory would override turning off the rule in the top-level .eslintrc.js file.

It also starts to move us in the direction of a single-top level configuration, which ESLint is currently heading towards.

I have considered having this list automatically generated from the build system/.ini files - maybe as part of running ESlint. However, that would potentially introduce an expensive build step, as well as being difficult for editors to handle. We might be able to do something to update the file in-place, but for now this is an intermediate step that would make it easier to do in future.


Reply all
Reply to author
0 new messages