-
Notifications
You must be signed in to change notification settings - Fork 68
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 npm-scripts to format .md and .yml files #92
Comments
Just quick comment, in
I'm assuming we don't want to format those in the |
Correct. My idea is to allow them to be formatted, but not to change the default globs in liferay-portal itself (because they are already handled there by the Java Source Formatter; we could look at handing over responsibility for those filetypes to Prettier in the future, but that would be a separate thing). |
Noticed while testing a PR for: #92 that we aren't applying our Liferay-specific Prettier overrides to TS files. ie. we're not enforcing this: } else { Test plan: Add a ".ts" file, "x.ts" with these contents: if (true) { alert('t'); } else { alert('f'); } Add an "npmscripts.config.js" file (you don't need the ".md" and ".yml" in there, but this is the file I had to create to test the other PR anyway, so I'm just using the same one): module.exports = { check: ['**/*.{md,ts,yml}'], fix: ['**/*.{md,ts,yml}'], } Run `projects/npm-tools/packages/npm-scripts/bin/liferay-npm-scripts.js check` and see the error reported. Run `projects/npm-tools/packages/npm-scripts/bin/liferay-npm-scripts.js fix` and see the code fixed to: if (true) { alert('t'); } else { alert('f'); }
Noticed while testing a PR for: #92 that we aren't applying our Liferay-specific Prettier overrides to TS files. ie. we're not enforcing this: } else { Test plan: Add a ".ts" file, "x.ts" with these contents: if (true) { alert('t'); } else { alert('f'); } Add an "npmscripts.config.js" file (you don't need the ".md" and ".yml" in there, but this is the file I had to create to test the other PR anyway, so I'm just using the same one): module.exports = { check: ['**/*.{md,ts,yml}'], fix: ['**/*.{md,ts,yml}'], } Run `projects/npm-tools/packages/npm-scripts/bin/liferay-npm-scripts.js check` and see the error reported. Run `projects/npm-tools/packages/npm-scripts/bin/liferay-npm-scripts.js fix` and see the code fixed to: if (true) { alert('t'); } else { alert('f'); }
We're not going to change the default globs in liferay-portal yet (or possibly ever?) because the Java Source Formatter currently handles these types. However, we can make it easier for non-liferay-portal projects like liferay-learn: https://github.com/liferay/liferay-learn that use liferay-npm-scripts to run Prettier over a broader range of files. It's a simple matter of expanding the list of allowed globs. Test plan: In order to actually test this I had these two PRs applied: - #101 - #102 Then, with this npmscripts.config.js at the top level of the monorepo: module.exports = { check: ['**/*.{md,ts,yml}'], fix: ['**/*.{md,ts,yml}'], } I created some bad files and ran `projects/npm-tools/packages/npm-scripts/bin/liferay-npm-scripts.js check` and saw these errors: x.md: BAD x.ts: BAD x.yml: BAD and then ran `check` and saw them get fixed. Then, for good measure, in a liferay-learn clone, I added "yml" and "md" to the globs in the npmscripts.config.js and repeated the test after a: npm install cp -R path/to/npm-scripts node_modules/@liferay/ ie. npm run format:check see: site/homepage/x.md: BAD site/homepage/x.yml: BAD Prettier checked 21 files, 2 files have problems Then: npm run format and see the errors fixed: Prettier checked 21 files, fixed 2 files Closes: #92
Issue type
Description
Desired behavior:
As per #91 βΒ they want to format YAML and Markdown too using
@liferay/npm-scripts
.Current behavior:
We only support a hard-coded list of file extensions for the reasons discussed in the linked issue.
The text was updated successfully, but these errors were encountered: