Skip to content

Adopt Prettier for JavaScript formatting #13581

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

Merged
merged 1 commit into from
May 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,21 @@ jobs:
run: |
python -m build .
twine check dist/*

prettier:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- run: >
npx [email protected]
--check
"sphinx/themes/**/*.js"
"!sphinx/themes/bizstyle/static/css3-mediaqueries*.js"
"tests/js/**/*.{js,mjs}"
"!tests/js/fixtures/**"
2 changes: 2 additions & 0 deletions .prettierrc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://prettier.io/docs/options
experimentalOperatorPosition = "start"
8 changes: 4 additions & 4 deletions sphinx/search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ class SearchLanguage:
/**
* Dummy stemmer for languages without stemming rules.
*/
var Stemmer = function() {
this.stemWord = function(w) {
var Stemmer = function () {
this.stemWord = function (w) {
return w;
}
}
};
};
"""

_word_re = re.compile(r'\w+')
Expand Down
11 changes: 6 additions & 5 deletions sphinx/themes/basic/static/doctools.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Documentation = {
Object.assign(Documentation.TRANSLATIONS, catalog.messages);
Documentation.PLURAL_EXPR = new Function(
"n",
`return (${catalog.plural_expr})`
`return (${catalog.plural_expr})`,
);
Documentation.LOCALE = catalog.locale;
},
Expand Down Expand Up @@ -89,7 +89,7 @@ const Documentation = {

const togglerElements = document.querySelectorAll("img.toggler");
togglerElements.forEach((el) =>
el.addEventListener("click", (event) => toggler(event.currentTarget))
el.addEventListener("click", (event) => toggler(event.currentTarget)),
);
togglerElements.forEach((el) => (el.style.display = ""));
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler);
Expand All @@ -98,14 +98,15 @@ const Documentation = {
initOnKeyListeners: () => {
// only install a listener if it is really needed
if (
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS &&
!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS
&& !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
)
return;

document.addEventListener("keydown", (event) => {
// bail for input elements
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName))
return;
// bail with special keys
if (event.altKey || event.ctrlKey || event.metaKey) return;

Expand Down
Loading
Loading