Add prettier
Prettier is a code formatter for javascript/typescript. It's relatively common to see complaints about style in pull requests or inconsistent style getting in to Collabora Online. Also, without a formatter it's harder for editors to automatically format code in sensible and consistent ways Prettier doesn't have many options, but those which it does have I have set to the closest values to current behavior (e.g. single quotes) in order to minimize unnecessary changes This commit doesn't format all existing files. Doing so would cause blames, cherry-picks and diffs to become much less useful. Instead, we use browser/.beforeprettier to list all files that would need to be changed, and this file is ignored. You are encouraged but not required to set your editor's equivalent of 'editor.formatOnSaveMode' to only format changed lines This commit also does format of docstatefunctions.js, previously it did not in to check that an incorrectly-formatted file could fail CI. Now it does to make sure that formatting fixes the issue. This file was chosen because it is very new and very small. Change-Id: Ie6067f34aa658f887e149a08aebd0180b2354005 Signed-off-by: Skyler Grey <skyler.grey@collabora.com>
This commit is contained in:
parent
fae5644eaa
commit
a40be5499e
7 changed files with 263 additions and 29 deletions
21
Makefile.am
21
Makefile.am
|
@ -508,7 +508,7 @@ COMMON_PARAMS = \
|
|||
--o:ssl.ca_file_path="$(abs_top_srcdir)/etc/ca-chain.cert.pem" \
|
||||
--o:admin_console.username=admin --o:admin_console.password=admin
|
||||
|
||||
run: setup-wsd
|
||||
run: prettier-write setup-wsd
|
||||
./coolwsd $(COMMON_PARAMS) \
|
||||
--o:security.capabilities="$(CAPABILITIES)" \
|
||||
--o:logging.file[@enable]=${OUTPUT_TO_FILE} --o:logging.level=trace \
|
||||
|
@ -649,6 +649,23 @@ eslint: browser/node_modules
|
|||
--no-eslintrc \
|
||||
--config browser/.eslintrc
|
||||
|
||||
prettier: browser/node_modules
|
||||
browser/node_modules/.bin/prettier \
|
||||
--config browser/.prettierrc \
|
||||
--ignore-path browser/.prettierignore \
|
||||
--ignore-path browser/.beforeprettier \
|
||||
--check \
|
||||
browser/src browser/js browser/admin/src \
|
||||
|| echo "To run prettier, you can use 'make prettier-write' or run COOLWSD with 'make run'"
|
||||
|
||||
prettier-write: browser/node_modules
|
||||
browser/node_modules/.bin/prettier \
|
||||
--config browser/.prettierrc \
|
||||
--ignore-path browser/.prettierignore \
|
||||
--ignore-path browser/.beforeprettier \
|
||||
--write \
|
||||
browser/src browser/js browser/admin/src
|
||||
|
||||
install-exec-hook:
|
||||
cd $(DESTDIR)$(bindir) && \
|
||||
$(LN_S) coolconfig loolconfig && \
|
||||
|
@ -692,7 +709,7 @@ check-for-system-nss:
|
|||
|
||||
check-recursive: eslint
|
||||
|
||||
check: check-for-system-nss eslint check-recursive
|
||||
check: check-for-system-nss prettier eslint check-recursive
|
||||
$(GEN_COVERAGE_COMMAND)
|
||||
|
||||
coverage-report:
|
||||
|
|
212
browser/.beforeprettier
Normal file
212
browser/.beforeprettier
Normal file
|
@ -0,0 +1,212 @@
|
|||
/src/control/ColorPicker.js
|
||||
/src/control/Control.AlertDialog.js
|
||||
/src/control/Control.Attribution.js
|
||||
/src/control/Control.ColumnGroup.ts
|
||||
/src/control/Control.ColumnHeader.ts
|
||||
/src/control/Control.Command.js
|
||||
/src/control/Control.ContextMenu.js
|
||||
/src/control/Control.CornerGroup.ts
|
||||
/src/control/Control.CornerHeader.ts
|
||||
/src/control/Control.DocumentNameInput.js
|
||||
/src/control/Control.DocumentRepair.js
|
||||
/src/control/Control.DownloadProgress.js
|
||||
/src/control/Control.FormulaBar.js
|
||||
/src/control/Control.FormulaBarJSDialog.js
|
||||
/src/control/Control.GroupBase.ts
|
||||
/src/control/Control.Header.ts
|
||||
/src/control/Control.IdleHandler.ts
|
||||
/src/control/Control.js
|
||||
/src/control/Control.JSDialog.js
|
||||
/src/control/Control.JSDialogBuilder.js
|
||||
/src/control/Control.LanguageDialog.js
|
||||
/src/control/Control.Layers.js
|
||||
/src/control/Control.LokDialog.js
|
||||
/src/control/Control.Mention.js
|
||||
/src/control/Control.Menubar.js
|
||||
/src/control/Control.MobileBottomBar.js
|
||||
/src/control/Control.MobileSlide.js
|
||||
/src/control/Control.MobileTopBar.js
|
||||
/src/control/Control.MobileWizard.js
|
||||
/src/control/Control.MobileWizardBuilder.js
|
||||
/src/control/Control.MobileWizardPopup.js
|
||||
/src/control/Control.MobileWizardWindow.js
|
||||
/src/control/Control.Notebookbar.js
|
||||
/src/control/Control.NotebookbarBuilder.js
|
||||
/src/control/Control.NotebookbarCalc.js
|
||||
/src/control/Control.NotebookbarDraw.js
|
||||
/src/control/Control.NotebookbarImpress.js
|
||||
/src/control/Control.NotebookbarWriter.js
|
||||
/src/control/Control.PartsPreview.js
|
||||
/src/control/Control.Permission.js
|
||||
/src/control/Control.PresentationBar.js
|
||||
/src/control/Control.RowGroup.ts
|
||||
/src/control/Control.RowHeader.ts
|
||||
/src/control/Control.Scroll.Annotation.js
|
||||
/src/control/Control.SearchBar.js
|
||||
/src/control/Control.Selection.js
|
||||
/src/control/Control.SheetsBar.js
|
||||
/src/control/Control.Sidebar.js
|
||||
/src/control/Control.StatusBar.js
|
||||
/src/control/Control.Tabs.js
|
||||
/src/control/Control.Toolbar.js
|
||||
/src/control/Control.TopToolbar.js
|
||||
/src/control/Control.UIManager.js
|
||||
/src/control/Control.UserList.js
|
||||
/src/control/Control.Zotero.js
|
||||
/src/control/IFrameDialog.js
|
||||
/src/control/jsdialog/Util.Dropdown.js
|
||||
/src/control/jsdialog/Util.FocusCycle.js
|
||||
/src/control/jsdialog/Util.ModalHelper.js
|
||||
/src/control/jsdialog/Util.StateChange.ts
|
||||
/src/control/jsdialog/Widget.Calendar.js
|
||||
/src/control/jsdialog/Widget.Combobox.js
|
||||
/src/control/jsdialog/Widget.DrawingArea.js
|
||||
/src/control/jsdialog/Widget.FormulabarEdit.js
|
||||
/src/control/jsdialog/Widget.Frame.js
|
||||
/src/control/jsdialog/Widget.IconView.js
|
||||
/src/control/jsdialog/Widget.LanguageSelector.js
|
||||
/src/control/jsdialog/Widget.MenuButton.js
|
||||
/src/control/jsdialog/Widget.MobileBorderSelector.js
|
||||
/src/control/jsdialog/Widget.MobileTabControl.js
|
||||
/src/control/jsdialog/Widget.MultilineEdit.js
|
||||
/src/control/jsdialog/Widget.Progressbar.js
|
||||
/src/control/jsdialog/Widget.ScrolledWindow.js
|
||||
/src/control/jsdialog/Widget.Timefield.js
|
||||
/src/control/jsdialog/Widget.TreeView.js
|
||||
/src/control/Parts.js
|
||||
/src/control/Permission.js
|
||||
/src/control/Ruler.js
|
||||
/src/control/Scroll.js
|
||||
/src/control/Search.js
|
||||
/src/control/Signing.js
|
||||
/src/control/Styles.js
|
||||
/src/control/Toolbar.js
|
||||
/src/core/Class.js
|
||||
/src/core/Debug.js
|
||||
/src/core/Events.js
|
||||
/src/core/Handler.js
|
||||
/src/core/Log.js
|
||||
/src/core/LOUtil.js
|
||||
/src/core/Matrix.js
|
||||
/src/core/Rectangle.ts
|
||||
/src/core/Socket.js
|
||||
/src/core/Util.js
|
||||
/src/docstate.js
|
||||
/src/dom/DomEvent.js
|
||||
/src/dom/DomEvent.MultiClick.js
|
||||
/src/dom/DomEvent.Pointer.js
|
||||
/src/dom/DomUtil.js
|
||||
/src/dom/Draggable.js
|
||||
/src/dom/NotebookbarAccessibility.js
|
||||
/src/dom/NotebookbarAccessibilityDefinitions.js
|
||||
/src/dom/PosAnimation.js
|
||||
/src/dom/PosAnimation.Timer.js
|
||||
/src/errormessages.js
|
||||
/src/geo/crs/CRS.js
|
||||
/src/geo/LatLng.js
|
||||
/src/geo/LatLngBounds.js
|
||||
/src/geo/projection/Projection.LonLat.js
|
||||
/src/geometry/Bounds.ts
|
||||
/src/geometry/LineUtil.js
|
||||
/src/geometry/Point.ts
|
||||
/src/geometry/PolyUtil.js
|
||||
/src/geometry/Transformation.ts
|
||||
/src/layer/BackgroundColor.js
|
||||
/src/layer/CalcSplitPanesContext.ts
|
||||
/src/layer/FeatureGroup.js
|
||||
/src/layer/FormFieldButtonLayer.js
|
||||
/src/layer/Layer.js
|
||||
/src/layer/Layer.Popup.js
|
||||
/src/layer/LayerGroup.js
|
||||
/src/layer/marker/A11yTextInput.js
|
||||
/src/layer/marker/Cursor.ts
|
||||
/src/layer/marker/DivIcon.js
|
||||
/src/layer/marker/Icon.Default.js
|
||||
/src/layer/marker/Icon.js
|
||||
/src/layer/marker/Marker.Drag.js
|
||||
/src/layer/marker/Marker.js
|
||||
/src/layer/marker/Marker.Popup.js
|
||||
/src/layer/marker/ProgressOverlay.js
|
||||
/src/layer/marker/TextInput.js
|
||||
/src/layer/Popup.js
|
||||
/src/layer/SplitPanesContext.ts
|
||||
/src/layer/tile/AutoFillMarkerSection.ts
|
||||
/src/layer/tile/CalcTileLayer.js
|
||||
/src/layer/tile/CanvasSectionContainer.ts
|
||||
/src/layer/tile/CanvasSectionProps.js
|
||||
/src/layer/tile/CanvasTileLayer.js
|
||||
/src/layer/tile/CommentListSection.ts
|
||||
/src/layer/tile/CommentSection.ts
|
||||
/src/layer/tile/ContentControlSection.ts
|
||||
/src/layer/tile/ImpressTileLayer.js
|
||||
/src/layer/tile/ScrollSection.ts
|
||||
/src/layer/tile/SheetGeometry.ts
|
||||
/src/layer/tile/SheetSwitch.ts
|
||||
/src/layer/tile/TileLayer.TableOverlay.js
|
||||
/src/layer/tile/TilesSection.ts
|
||||
/src/layer/tile/WriterTileLayer.js
|
||||
/src/layer/vector/Canvas.js
|
||||
/src/layer/vector/CanvasOverlay.ts
|
||||
/src/layer/vector/CDarkOverlay.ts
|
||||
/src/layer/vector/CEventsHandler.ts
|
||||
/src/layer/vector/Circle.js
|
||||
/src/layer/vector/CircleMarker.js
|
||||
/src/layer/vector/CLineUtil.ts
|
||||
/src/layer/vector/CPath.ts
|
||||
/src/layer/vector/CPointSet.ts
|
||||
/src/layer/vector/CPolygon.ts
|
||||
/src/layer/vector/CPolyline.ts
|
||||
/src/layer/vector/CPolyUtil.ts
|
||||
/src/layer/vector/CRectangle.ts
|
||||
/src/layer/vector/CSplitterLine.ts
|
||||
/src/layer/vector/Path.Drag.js
|
||||
/src/layer/vector/Path.Drag.Transform.js
|
||||
/src/layer/vector/Path.js
|
||||
/src/layer/vector/Path.Popup.js
|
||||
/src/layer/vector/Path.Transform.Canvas.js
|
||||
/src/layer/vector/Path.Transform.js
|
||||
/src/layer/vector/Path.Transform.SVG.js
|
||||
/src/layer/vector/Path.Transform.SVG.VML.js
|
||||
/src/layer/vector/Path.Transform.Util.js
|
||||
/src/layer/vector/Polygon.js
|
||||
/src/layer/vector/Polyline.js
|
||||
/src/layer/vector/Rectangle.js
|
||||
/src/layer/vector/Renderer.js
|
||||
/src/layer/vector/SplitPanesRenderer.js
|
||||
/src/layer/vector/SplitPanesSVG.js
|
||||
/src/layer/vector/SVG.js
|
||||
/src/layer/vector/SVG.VML.js
|
||||
/src/layer/vector/SVGGroup.js
|
||||
/src/main.js
|
||||
/src/map/anim/Map.PanAnimation.js
|
||||
/src/map/Clipboard.js
|
||||
/src/map/handler/Map.DoubleClickZoom.js
|
||||
/src/map/handler/Map.Drag.js
|
||||
/src/map/handler/Map.Feedback.js
|
||||
/src/map/handler/Map.FileInserter.js
|
||||
/src/map/handler/Map.Keyboard.js
|
||||
/src/map/handler/Map.KeyboardShortcuts.ts
|
||||
/src/map/handler/Map.Mouse.js
|
||||
/src/map/handler/Map.Print.js
|
||||
/src/map/handler/Map.Scroll.js
|
||||
/src/map/handler/Map.SlideShow.js
|
||||
/src/map/handler/Map.StateChanges.js
|
||||
/src/map/handler/Map.TouchGesture.js
|
||||
/src/map/handler/Map.VersionBar.js
|
||||
/src/map/handler/Map.Welcome.js
|
||||
/src/map/handler/Map.WOPI.js
|
||||
/src/map/Map.js
|
||||
/src/UNO/Key.js
|
||||
/js/global.js
|
||||
/js/ResizeObserverPolyfill.js
|
||||
/admin/src/AdminClusterOverview.js
|
||||
/admin/src/AdminClusterOverviewAbout.js
|
||||
/admin/src/AdminSocketAnalytics.js
|
||||
/admin/src/AdminSocketBase.js
|
||||
/admin/src/AdminSocketHistory.js
|
||||
/admin/src/AdminSocketLog.js
|
||||
/admin/src/AdminSocketOverview.js
|
||||
/admin/src/AdminSocketSettings.js
|
||||
/admin/src/Base.js
|
||||
/admin/src/ModalDialogCreator.ts
|
||||
/admin/src/Util.js
|
|
@ -1,25 +1,18 @@
|
|||
{
|
||||
"extends": "eslint:recommended",
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"prettier"
|
||||
],
|
||||
"rules": {
|
||||
"camelcase": 2,
|
||||
"quotes": [2, "single"],
|
||||
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
|
||||
"space-in-parens": 2,
|
||||
"space-before-blocks": 2,
|
||||
"keyword-spacing": 2,
|
||||
"no-lonely-if": 2,
|
||||
"comma-style": 2,
|
||||
"indent": "off",
|
||||
"no-underscore-dangle": 0,
|
||||
"no-constant-condition": 0,
|
||||
"no-multi-spaces": 0,
|
||||
"strict": 0,
|
||||
"key-spacing": 0,
|
||||
"no-shadow": 0,
|
||||
"no-console": 0,
|
||||
"no-control-regex": 0,
|
||||
"no-useless-escape": 0,
|
||||
"semi": 2,
|
||||
"no-redeclare": 0,
|
||||
/// Rules that are set to warn will fail in CI but not when building for development:
|
||||
"no-debugger": 1,
|
||||
|
|
10
browser/.prettierignore
Normal file
10
browser/.prettierignore
Normal file
|
@ -0,0 +1,10 @@
|
|||
# We only directly edit toolbar.js in dist/
|
||||
**/js/Autolinker.js
|
||||
**/js/select2.js
|
||||
**/js/sanitize-url.js
|
||||
**/js/l10n.js
|
||||
**/js/w2ui-1.5.rc1.js
|
||||
**/src/unocommands.js
|
||||
**/js/viamapi-client.js
|
||||
node_modules
|
||||
dist/src
|
1
browser/.prettierrc
Normal file
1
browser/.prettierrc
Normal file
|
@ -0,0 +1 @@
|
|||
singleQuote: true
|
|
@ -18,6 +18,7 @@
|
|||
"canvas": "^2.6.1",
|
||||
"d3": "6.7.0",
|
||||
"eslint": "7.0.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"fzstd": "0.1.0",
|
||||
"hammerjs": "2.0.8",
|
||||
"jquery": "3.5.1",
|
||||
|
@ -27,6 +28,7 @@
|
|||
"jscpd": "3.5.10",
|
||||
"l10n-for-node": "0.0.1",
|
||||
"mocha": "8.2.1",
|
||||
"prettier": "^3.1.1",
|
||||
"select2": "4.0.13",
|
||||
"shrinkpack": "1.0.0-alpha",
|
||||
"smartmenus": "1.0.0",
|
||||
|
|
|
@ -15,30 +15,29 @@
|
|||
|
||||
/* global app */
|
||||
|
||||
app.isReadOnly = function() {
|
||||
app.isReadOnly = function () {
|
||||
return app.file.readOnly;
|
||||
};
|
||||
|
||||
app.isCommentEditingAllowed = function() {
|
||||
app.isCommentEditingAllowed = function () {
|
||||
return app.file.editComment;
|
||||
};
|
||||
|
||||
app.setPermission = function(permission) {
|
||||
app.file.permission = permission;
|
||||
if (permission === 'edit') {
|
||||
app.file.readOnly = false;
|
||||
app.file.editComment = true;
|
||||
}
|
||||
else if (permission === 'readonly') {
|
||||
app.file.readOnly = true;
|
||||
app.file.editComment = false;
|
||||
}
|
||||
app.setPermission = function (permission) {
|
||||
app.file.permission = permission;
|
||||
if (permission === 'edit') {
|
||||
app.file.readOnly = false;
|
||||
app.file.editComment = true;
|
||||
} else if (permission === 'readonly') {
|
||||
app.file.readOnly = true;
|
||||
app.file.editComment = false;
|
||||
}
|
||||
};
|
||||
|
||||
app.setCommentEditingPermission = function(isAllowed) {
|
||||
app.file.editComment = isAllowed;
|
||||
app.setCommentEditingPermission = function (isAllowed) {
|
||||
app.file.editComment = isAllowed;
|
||||
};
|
||||
|
||||
app.getPermission = function() {
|
||||
return app.file.permission;
|
||||
app.getPermission = function () {
|
||||
return app.file.permission;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue