anandthakker / doiuse

:bomb: Lint CSS for browser support against caniuse database.
MIT License
1.24k stars 51 forks source link

Add .json extension to caniuse-db require statements #58

Closed neezer closed 7 years ago

neezer commented 7 years ago

I ran into an issue using the stylelint-webpack-plugin, which lists this library as a dependency. Specifically, my tests for my webpack config were failing like so:

screenshot of failing tests

I searched my node_modules folder for the offending require and noticed that all other projects that list this library import caniuse-db/* with the .json extension, except this one.

screenshot of other libraries that require doiuse

Since my test setup is not currently configured to resolve the .json extension (as I currently have no need to yet), this was causing my test to fail.

I could solve by adding .json to the list of extensions like so

{
  "jest": {
    "moduleFileExtensions": [
      "js",
      "jsx",
      "json", // <----
      "css"
    ]
  }
}

... but really I'd only be doing this to make up for this change in a buried dependency, which doesn't feel right. Plus I'd probably have to add a comment in my code base so that other developers on my project wouldn't remove this, get the same error, and be scratching their heads as to why.

Given that there seems to be some symmetry between other libraries that require JSON data from caniuse-db, I thought a better solution would be to open this PR and just add the extensions.


Let me know if I need to make any other edits to make this a well-formed PR; not a usual OS contributor. 😄

neezer commented 7 years ago

Looks like CI failed for linting issues unrelated to my changeset:

ss

Want me to fix those, even though they're orthogonal to my proposed change?

wrumsby commented 7 years ago

@neezer @anandthakker these failing linting issues should be fixed in #59.

anandthakker commented 7 years ago

Thanks for the CI fix @wrumsby -- just merged that in, so @neezer if you could rebase this branch onto master, then I think it's good to 🚢

(sorry, btw, for the late reply here)

neezer commented 7 years ago

@anandthakker Updated!

anandthakker commented 7 years ago

Thanks @neezer !