Hi, thanks for the comments!
For using the stylelint experimental “fix” feature, I looked at the source code for the jest runner that I’m using. I experimented by changing run.js
in my node_modules
to have the following code.
const { pass, fail } = require("create-jest-runner");
const stylelint = require("stylelint");module.exports = ({ testPath, config, globalConfig }) => {
const start = new Date();return stylelint
.lint({
files: testPath,
formatter: "string",
fix: true,
})
.then(data => {
if (data.errored) {
return fail({
start,
end: new Date(),
test: {
path: testPath,
errorMessage: data.output
}
});
}return pass({
start,
end: new Date(),
test: { path: testPath }
});
})
.catch(err => {
throw err;
});
};
Then when the jest css linting, it fixed the errors ( for example, it rewrote 0px
as 0
.
For indentation, I’m not really sure. I always use prettier. 🙈