Looking to make some small modifications to core eslint rules like array-bracket-newline
or indent
? These rules often rely on utilities within eslint
, particularly ast-utils
. Up until now, I've been using a plugin to add the modified rules and performing a
require('eslint/lib/rules/utils/ast-utils')
, since eslint
is a peer-dependency.
However, due to recent changes in https://github.com/eslint/eslint/commit/24c9f2ac57efcd699ca69695c82e51ce5742df7b, this method is no longer feasible with the addition of an exports
directive in the package.json
. What is the recommended approach for modifying core eslint rules now?
- Manually extracting all dependencies could work, but it's laborious and results in unnecessary code duplication (having to identify and remove segments of eslint's code).
- Forking
eslint
entirely seems messy, given its interconnectedness with other components like eslint-plugins, vscode extensions, yarn sdks, etc. This would require adjustments across the board or resorting to questionable renaming tactics that could lead to confusion. - Using yarn package patching to eliminate the
exports
appears distasteful.
Is there a cleaner alternative?
As of now, my best solution involves forking eslint
, eliminating the exports
, and utilizing
require('eslint-fork/lib/rules/utils/ast-utils')
within the fork. While this means having an additional copy of eslint
unnecessarily, considering it's for linting purposes, a bit of extra disk space seems inconsequential.