solana-labs / eslint-plugin-require-extensions

Apache License 2.0
53 stars 6 forks source link

fix: only apply to modules #3

Closed tpluscode closed 1 year ago

tpluscode commented 1 year ago

This is an attempt to fix #1

I would like to add some tests but this is my first time writing code for an eslint plugins and not sure how to proceed

About the change itself, it find the actual module in the filesystem and applies to rule only when a module exists with one of the extensions

For example, given code like

import foo from './bar.json'

An error will be shown when there is a source file bar.json.js or bar.json.ts but not when it's simply bar.json

I'm not sure if it's correct to also include jsx and tsx in the extensions to check.

tpluscode commented 1 year ago

Ping @jordansexton ?

jordaaash commented 1 year ago

@tpluscode Ah, thanks for the ping, didn't see this. Will review today.

tpluscode commented 1 year ago

Super, thanks

tpluscode commented 1 year ago

Aha, I wrote that lengthy reply before realising I misunderstood your point. 😅

Yes, you're right, a file which does no exist should have the .js suffix added which will inevitably lead to a different rule kicking in, or TS compiler error, ot runtime loader error. Not this plugin's concern

There are quite some cases, some of which are not handled by this PR not the base branch. It would really be good to add unit tests but I do not have experience testing eslint rules. Do you?

tpluscode commented 1 year ago

What do you think about my updated code @jordansexton ?

jordaaash commented 1 year ago

Published in v0.1.2! Please let me know if it works well for you, and thank you for working on this!

tpluscode commented 1 year ago

Super, thanks for releasing