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
Support .mjs
configuration files
#6905
Comments
I think this should just work. The only hurdle is that we can't write tests for this with |
Unfortunately, my try for
{
"devDependencies": {
"stylelint": "^15.7.0"
},
"scripts": {
"test": "stylelint -c config.mjs *.css",
"test-cjs": "stylelint -c config.cjs *.css"
}
}
export default {
rules: {
"block-no-empty": true,
},
};
module.exports = {
rules: {
"block-no-empty": true,
},
};
a{} Run: $ npm i
...
$ npm test
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/masafumi.koba/tmp/foo/config.mjs not supported.
Instead change the require of /Users/masafumi.koba/tmp/foo/config.mjs to a dynamic import() which is available in all CommonJS modules.
...
$ npm run test-cjs
test.css
1:2 ✖ Unexpected empty block block-no-empty
1 problem (1 error, 0 warnings) |
Was that with or without the |
We can write test for |
Good catch! Using the HEAD version of "devDependencies": {
- "stylelint": "^15.7.0"
+ "stylelint": "github:stylelint/stylelint"
},
It might be ideal for writing tests, but I don't think writing tests for this feature is essential because writing tricky tests for the feature Cosmiconfig provides has very few benefits. So, we can just update the CLI help and the document to close this issue! I've labeled the issue as ready to implement. Please consider contributing if you have time. |
What is the problem you're trying to solve?
Cosmiconfig has supported
.mjs
files since v8.2. I believe it'd be useful if Stylelint also could support it.What solution would you like to see?
First, we may need to resolve a problem with loaders. It may not be easy.
stylelint/lib/createStylelint.js
Lines 22 to 27 in 2413e8f
Then, we must update the CLI help and documentation below:
stylelint/lib/cli.js
Lines 115 to 118 in 2413e8f
stylelint/docs/user-guide/configure.md
Lines 3 to 8 in 2413e8f
See also:
The text was updated successfully, but these errors were encountered: