eslint-plugin-canonical
eslint-plugin-canonical copied to clipboard
fix: make rules behave consistently on win32
I noticed that multiple rules have a few issues on Windows:
-
no-barrel-import
,virtual-module
, andrequire-extension
all assume/
is the root of the fs on Windows, which ain't the case. -
prefer-import-alias
,require-extensions
mix up the ECMA path separator and the OS path separator, which are not the same on Windows. -
virtual-module
mixed up the ECMA path separator and the OS path separator as well, but only in the logging, which can be confusing nonetheless.
https://github.com/gajus/eslint-plugin-canonical/blob/main/src/rules/virtualModule.ts#L29
https://github.com/gajus/eslint-plugin-canonical/blob/main/src/rules/noBarrelImport.ts#L84
To solve that, I propose the following:
-
In d7880fb, I move the ci setup from a single job to a matrix job that runs on both ubuntu-latest and windows-latest. We can see there that the CI does fail already, despite no changes in the source code.
-
Make everything works on Windows (todo addcommit sha):
- Add a util to find the rootPath (so on Windows
C:/
, or some other letters and on Unix/
. Leverage it wherever/
was used directly withfindDirectory
. This fix issue 1 - Normalize paths using
.replaceAll(win32Sep, posixSep)
. This fixes the two other issues
- Add a util to find the rootPath (so on Windows
any reason for not merging this one - as currently some of the rules - like virtual-module - do not function properly on windows ?
Just did not see notifications for this until I had to do a random update.
Just did not see notifications for this until I had to do a random update.
@gajus , I rebased my branch so that it ain't a hassle to review/test, tell me if you need anything ;)