charlierudolph / dependency-lint

Lints NPM dependencies and devDependencies
MIT License
14 stars 6 forks source link

Know about common transpilers #31

Open kevgo opened 7 years ago

kevgo commented 7 years ago

Transpilers users shouldn't have to educate dependency-lint about which extensions CoffeeScript uses and how to load it's compiler. https://github.com/js-cli/js-interpret provides this information for all common transpilers, and https://github.com/js-cli/js-rechoir allows to register transpilers so that CoffeeScript files can be required directly.

@charlierudolph

charlierudolph commented 7 years ago

I don't think thats helpful to dependency-lint which isn't requiring the each source file. Instead it needs to compile them to javascript, so it can parse the code structure and find the require calls. See the configuration doc for more details about how the section is used.

kevgo commented 7 years ago

I still have to set this up for every repo. Which happens just infrequently enough that I never remember the syntax, and have to look it up in your docs again. 😬 And the config information I have to provide in dependency-lint.yml is pretty much the same as listed in https://github.com/js-cli/js-interpret... It would be nice if Dependency-Lint would know how to transpile source code based on this information on its own.

Its not the end of the world if this doesn't happen, I am complaining on a very high level here :)

charlierudolph commented 7 years ago

Just looking at this again, I think we would need a node module similar to js-interpret that maps the file extension to a function which transforms code in that language into javascript. Would just need to look through the doc on the JS api of each we want to support.

charlierudolph commented 7 years ago

Just implemented this: https://github.com/charlierudolph/js-transpile. Need to add a readme and integrate it into dependency-lint

OmgImAlexis commented 7 years ago

@charlierudolph opened an issue on js-transpile since this won't detect ES6 in .js files since you made it assume people are using .babel.js even though that's not the case with most repos.