-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add Stylelint checks and checks output consistency #377
Conversation
size-limit report 📦
|
src/checks/stylelingConfigIsValid.ts
Outdated
module.exports = config;`; | ||
} catch (err) { | ||
throw new Error( | ||
`Error reading your stylelint.config.cjs file. Please reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I guess this error should mention that the config file should be deleted if it exists
- Probably we want to mention this for the same error in the ESLint config check
- the period can be changed to this pattern: d242231
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/checks/stylelingConfigIsValid.ts
Outdated
|
||
if (!stylelintConfigMatches) { | ||
throw new Error( | ||
`Your Stylelint config file stylelint.config.cjs does not match the configuration file template. Please reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I guess this error should mention that the config file should be deleted if it exists
- Probably we want to mention this for the same error in the ESLint config check
- the period can be changed to this pattern: d242231
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/checks/stylelingConfigIsValid.ts
Outdated
})) { | ||
const fileContents = await fs.readFile(path, 'utf-8'); | ||
if ( | ||
/stylelint-disable|stylelint [a-z0-9@/-]+: (0|off)/.test(fileContents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the second part of this pattern a valid way to ignore code in Stylelint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/index.ts
Outdated
@@ -87,6 +91,6 @@ await new Listr(listrTasks, { | |||
removeEmptyLines: false, | |||
formatOutput: 'wrap', | |||
}, | |||
fallbackRenderer: 'verbose', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably a merge mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 94 in 58f22fa
fallbackRenderer: 'verbose', |
the output in the description needs to be updated with the Preflight output including Stylelint config check too |
This reverts commit 4ad180a.
src/checks/eslint.ts
Outdated
|
||
// If no ESLint problems detected, throw the error | ||
if (!/^\d+ problems?$/.test(lines[lines.length - 2]!)) { | ||
if (!new RegExp(`"${errorKey}":`).test(stdout)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong, it won't fail on warnings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clarification, it looks like errorCount
may always exist, but it's relying on an implementation detail to assume that it will always be there when there are problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of checking for two dynamic keys, look at your data when you have no errors, maybe you can see a better way of checking it
@@ -20,6 +22,8 @@ import { | |||
projectPackageJson, | |||
} from './util/packageJson.js'; | |||
|
|||
const projectDependencies = projectPackageJson.dependencies || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like this pattern better than what we have, let's copy it over in these 2 places here too:
const { devDependencies = {}, dependencies = {} } = projectPackageJson; projectPackageJson.dependencies!,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 560b36a
src/checks/eslint.ts
Outdated
${(JSON.parse(stdout) as ESLint.LintResult[]) | ||
.filter( | ||
(eslintResult) => | ||
!(eslintResult[errorKey] === 0 && eslintResult[warningKey] === 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would this be the case? what is a a LintResult
which has both errorCount
and warningCount
both of 0
? does this happen in reality?
if it does, then this probably needs a comment describing when this is the case
Following a similar approach to the ESLint check, this PR adds a check for Stylelint to Preflight. The implemented features are:
css
,sass
,scss
,less
,js
,tsx
andjsx
filesupleveled-stylelint-config
packageIn addition This PR updates outputs for ESLint check and Prettier check in order to have a single path format for the output
New UpLeveled Prefilght output: