Skip to content

Commit 2c2159f

Browse files
authored
Adopt Prettier for JavaScript formatting (#13581)
1 parent 1a69059 commit 2c2159f

File tree

12 files changed

+314
-221
lines changed

12 files changed

+314
-221
lines changed

.github/workflows/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,21 @@ jobs:
123123
run: |
124124
python -m build .
125125
twine check dist/*
126+
127+
prettier:
128+
runs-on: ubuntu-latest
129+
130+
steps:
131+
- uses: actions/checkout@v4
132+
- name: Set up Node.js
133+
uses: actions/setup-node@v4
134+
with:
135+
node-version: "20"
136+
cache: "npm"
137+
- run: >
138+
npx prettier@3.5
139+
--check
140+
"sphinx/themes/**/*.js"
141+
"!sphinx/themes/bizstyle/static/css3-mediaqueries*.js"
142+
"tests/js/**/*.{js,mjs}"
143+
"!tests/js/fixtures/**"

.prettierrc.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# https://prettier.io/docs/options
2+
experimentalOperatorPosition = "start"

sphinx/search/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ class SearchLanguage:
8181
/**
8282
* Dummy stemmer for languages without stemming rules.
8383
*/
84-
var Stemmer = function() {
85-
this.stemWord = function(w) {
84+
var Stemmer = function () {
85+
this.stemWord = function (w) {
8686
return w;
87-
}
88-
}
87+
};
88+
};
8989
"""
9090

9191
_word_re = re.compile(r'\w+')

sphinx/themes/basic/static/doctools.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const Documentation = {
5959
Object.assign(Documentation.TRANSLATIONS, catalog.messages);
6060
Documentation.PLURAL_EXPR = new Function(
6161
"n",
62-
`return (${catalog.plural_expr})`
62+
`return (${catalog.plural_expr})`,
6363
);
6464
Documentation.LOCALE = catalog.locale;
6565
},
@@ -89,7 +89,7 @@ const Documentation = {
8989

9090
const togglerElements = document.querySelectorAll("img.toggler");
9191
togglerElements.forEach((el) =>
92-
el.addEventListener("click", (event) => toggler(event.currentTarget))
92+
el.addEventListener("click", (event) => toggler(event.currentTarget)),
9393
);
9494
togglerElements.forEach((el) => (el.style.display = ""));
9595
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler);
@@ -98,14 +98,15 @@ const Documentation = {
9898
initOnKeyListeners: () => {
9999
// only install a listener if it is really needed
100100
if (
101-
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS &&
102-
!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
101+
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS
102+
&& !DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
103103
)
104104
return;
105105

106106
document.addEventListener("keydown", (event) => {
107107
// bail for input elements
108-
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
108+
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName))
109+
return;
109110
// bail with special keys
110111
if (event.altKey || event.ctrlKey || event.metaKey) return;
111112

0 commit comments

Comments
 (0)