bmatcuk / eslint-plugin-postcss-modules

Checks that you are using the classes exported by your css modules using postcss.
MIT License
21 stars 7 forks source link

Only load deasync module if needed #31

Open zacharyliu opened 2 years ago

zacharyliu commented 2 years ago

The deasync module is not compatible with Electron (https://github.com/abbr/deasync/issues/81), making it impossible to use this plugin with VSCode's ESLint plugin since it errors on load. But this module is only actually needed if an async postcss config is encountered, which is not the default. Moving the require call inside of the function body means that we don't load the module unless it's needed.

I was able to verify that the plugin works in VSCode after this change, but I'm not sure the best way to test this with the automated tests given that deasync also doesn't work in them. One option is to mock the deasync module and assert that it is/isn't called in the parser test.