Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow linting JS as modules #128

Closed
DVLP opened this issue Oct 20, 2021 · 7 comments
Closed

Allow linting JS as modules #128

DVLP opened this issue Oct 20, 2021 · 7 comments

Comments

@DVLP
Copy link

DVLP commented Oct 20, 2021

In most projects I've seen people using .js for modules and almost never .mjs. Being unable to configure this requires entire codebase refactor just to try rslint so making this configurable should make adoption by the community much faster.

@DVLP DVLP changed the title Allow using linting JS as modules Allow linting JS as modules Oct 20, 2021
@Stupremee
Copy link
Member

What would your suggestion to solve it be? And what does eslint do in this case?

I'm wondering if #39 is enough of a solution or if there should be more to configure it.

@DVLP
Copy link
Author

DVLP commented Oct 21, 2021

ESlint has this option in eslintrc

"parserOptions": {
    "ecmaVersion": 10,
    "sourceType": "module"
},

"sourceType" can be either "module" or "script"
I'd suggest adding the same option in rslintrc

@DVLP
Copy link
Author

DVLP commented Mar 25, 2022

bump,
another way which I recently used in my run-func project is reading property type from package.json. If type == "module" then the files in this folder will be treated as modules without having to use .mjs extension. It's a standard way and that's also how node recognises modules.

https://nodejs.org/api/packages.html#determining-module-system
Under "Determining module system"

@Stupremee
Copy link
Member

Fixed in 7bc011e

@Stupremee
Copy link
Member

[parser]
source-type = "module"

Add this to your rslintrc.toml and it should work! I will probably do a release soon

@DVLP
Copy link
Author

DVLP commented Mar 28, 2022

Great! btw You should secure rslint package name ASAP!!! Otherwise someone else will register it, maybe even out of good will but then will stop updating it and will waste it.
https://www.npmjs.com/package/rslint

@Stupremee
Copy link
Member

Thanks for the tip. Will do that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants