Fix prettier usage (#1172)

After some discussion in #1166, I realized that our prettier workflow is somewhat broken! This PR fixes it, by:

- separating Stylelint & Prettier (and removing `stylelint-prettier`) to clearly separate linting versus formatting 
    - this is also helpful for the upcoming upgrading of Stylelint
- having Prettier ignore `assets/js/zzzz-search-data.json`; on `main`, `npm run format` fails because of this file (Prettier doesn't know how to interpret the front matter)
- change `npm test` to run both Stylelint and Prettier on CI (uses `npm-run-all` utility
    - had to add one `// prettier-ignore` in `_includes/mermaid_config.js`, which I think is reasonably placed
- removing an unused `script` (that doesn't work!)

This is a no-op on the site itself, just for our dev environment/CI.

Ref: https://github.com/just-the-docs/just-the-docs/pull/1166#discussion_r1110397592.

---

Separately, upgrading to Stylelint 15 will come with another interaction - the [deprecation of stylistic rules](https://stylelint.io/migration-guide/to-15#deprecated-stylistic-rules) + shift to Prettier should be nice!
This commit is contained in:
Matt Wang 2023-03-02 00:05:39 -08:00 committed by GitHub
parent 1289f6866f
commit 56a2dc560a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1655 additions and 163 deletions

View File

@ -1,4 +1,3 @@
package.json
package-lock.json
_site
assets/css/just-the-docs-default.scss
@ -6,5 +5,6 @@ assets/css/just-the-docs-light.scss
assets/css/just-the-docs-dark.scss
assets/js/vendor/lunr.min.js
assets/js/search-data.json
assets/js/zzzz-search-data.json
assets/js/just-the-docs.js
*.md

View File

@ -9,9 +9,7 @@
"stylelint-config-standard-scss",
"stylelint-config-prettier-scss"
],
"plugins": ["stylelint-prettier"],
"rules": {
"prettier/prettier": true,
"alpha-value-notation": null,
"color-function-notation": null,
"no-descending-specificity": null,

View File

@ -1 +1,2 @@
// prettier-ignore
{}

1803
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,15 +6,17 @@
"license": "MIT",
"bugs": "https://github.com/just-the-docs/just-the-docs/issues",
"devDependencies": {
"npm-run-all": "^4.1.5",
"prettier": "^2.8.4",
"stylelint": "^14.16.1",
"stylelint-config-prettier-scss": "0.0.1",
"stylelint-config-standard-scss": "^6.1.0",
"stylelint-prettier": "^2.0.0"
"stylelint-config-standard-scss": "^6.1.0"
},
"scripts": {
"test": "stylelint '**/*.scss'",
"lint": "npm-run-all --parallel --continue-on-error lint:*",
"lint:css": "stylelint '**/*.scss'",
"lint:formatting": "prettier --check '**/*.{scss,js,json}'",
"format": "prettier --write '**/*.{scss,js,json}'",
"stylelint-check": "stylelint-config-prettier-check"
"test": "npm run lint"
}
}