Skip to content
This repository has been archived by the owner on Feb 16, 2025. It is now read-only.

Commit

Permalink
Merge pull request #3066 from sanssecours/🦚
Browse files Browse the repository at this point in the history
Style: Reformat JavaScript Code
  • Loading branch information
markus2330 authored Oct 24, 2019
2 parents 161f635 + 570465d commit 8d138a2
Show file tree
Hide file tree
Showing 97 changed files with 6,838 additions and 6,025 deletions.
64 changes: 45 additions & 19 deletions doc/CODING.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,50 @@ Most notably use:
- Variable and function names in lowerCamelCase
- K & R style brackets

### JavaScript Guidelines

#### Prettier

We use [`prettier`][] to format JavaScript files.

##### Installation

###### macOS

On macOS you can install [`prettier`][] using [Homebrew][]:

```sh
brew install prettier
```

.

###### General

To install [`prettier`][] using Node’s package manager [npm](https://www.npmjs.com) you can use the command below

```sh
npm install --global prettier@1.18.2
```

.

##### Usage

To format all JavaScript files in the repository you can use the script [`reformat-javascript`](../scripts/dev/reformat-javascript):

```sh
scripts/dev/reformat-javascript
```

. To format only some files, please specify a list of filenames after the command:

```sh
scripts/dev/reformat-markdown src/tools/qt-gui/qml/ErrorDialogCreator.js # Reformat this file
```

.

### Markdown Guidelines

- File Ending is `.md` or integrated within Doxygen comments
Expand Down Expand Up @@ -393,25 +437,7 @@ that you can

##### Installation

###### macOS

On macOS you can install [`prettier`][] using [Homebrew][]:

```sh
brew install prettier
```

.

###### General

To install [`prettier`][] using Node’s package manager [npm](https://www.npmjs.com) you can use the command below

```sh
npm install --global prettier@1.17.1
```

.
For information on how to install the tool, please take a look at “JavaScript Guidelines” → “Prettier” → “Installation”.

##### Usage

Expand Down
2 changes: 1 addition & 1 deletion doc/news/_preparation_next_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ you up to date with the multi-language support provided by Elektra.
- We removed a script used to compare the runtime performance of YAML plugins. _(René Schwaiger)_
- Cleanup: separation of dev, admin and completion scripts. _(Markus Raab, Rene Schwaiger)_
- Pre-commit hook `pre-commit-check-formatting` now lives in [`scripts/dev/pre-commit-check-formatting`](../../scripts/dev/pre-commit-check-formatting). _(Klemens Böswirth)_
- <<TODO>>
- The new script [reformat-javascript](../../scripts/dev/reformat-javascript) formats the JavaScript code of the repository using the tool [`prettier`](https://prettier.io). _(René Schwaiger)_

## Cleanup

Expand Down
30 changes: 30 additions & 0 deletions scripts/dev/reformat-javascript
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
#
# @author René Schwaiger <sanssecours@me.com>
# @brief Reformat JavaScript files
# @date 13.10.2019
# @tags reformat

SCRIPTS_DIR=$(dirname "$0")
. "${SCRIPTS_DIR}/include-common"

cd "$SOURCE" || {
printf 'Unable to change into source directory'
exit 1
}

PRETTIER="$(which prettier)"

if [ -z "${PRETTIER}" ]; then
printf 2>&1 'Please install `prettier`\n'
exit 1
fi

if [ $# -gt 0 ]; then
javascript_files=$(printf "%s\n" "$@" | grep -Ex '.*\.jsx?')
[ -z "$javascript_files" ] && exit
else
# The file `TooltipCreator.js` contains the text `.pragma library`, which is not valid JavaScript code.
javascript_files=$(git ls-files '*.js' '*.jsx' | grep -v 'src/tools/qt-gui/qml/TooltipCreator.js')
fi
printf "%s\n" "$javascript_files" | sed -nE 's/(.*)/'"'"'\1'"'"'/p' | xargs "${PRETTIER}" --write --
4 changes: 2 additions & 2 deletions scripts/dev/reformat-markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# @author René Schwaiger <sanssecours@me.com>
# @brief Reformat Markdown files
# @date 13.02.20189
# @date 13.02.2019
# @tags reformat

SCRIPTS_DIR=$(dirname "$0")
Expand All @@ -16,7 +16,7 @@ cd "$SOURCE" || {
PRETTIER="$(which prettier)"

if [ -z "${PRETTIER}" ]; then
printf 2>&1 'Please install `prettier` (npm install --global prettier@1.16.4)\n'
printf 2>&1 'Please install `prettier` (npm install --global prettier@1.18.2)\n'
exit 1
fi

Expand Down
61 changes: 31 additions & 30 deletions scripts/docker/debian/jessie/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,47 @@ ENV LANGUAGE C.UTF-8
ENV LC_ALL C.UTF-8

RUN apt-get update && apt-get -y install \
curl \
build-essential \
autotools-dev \
automake \
autotools-dev \
build-essential \
checkinstall \
cmake \
pkg-config \
ruby \
ruby-dev \
python-dev \
python3-dev \
libpython3-dev \
curl \
dh-lua \
liblua5.2-dev \
tclcl-dev \
libaugeas-dev \
libbotan1.10-dev \
libgpgme11-dev \
libyajl-dev \
gawk \
git \
libgit2-dev \
gobject-introspection \
lcov \
libaugeas-dev \
libboost-all-dev \
libssl-dev \
libbotan1.10-dev \
libdbus-1-dev \
libpcre3-dev \
libpcre++-dev \
libev-dev \
libgirepository1.0-dev \
libgit2-dev \
libglib2.0-dev \
libxerces-c-dev \
swig3.0 \
libgpgme11-dev \
liblua5.2-dev \
libpcre++-dev \
libpcre3-dev \
libpython3-dev \
libssl-dev \
libsystemd-dev \
libuv0.10-dev \
libev-dev \
libxerces-c-dev \
libyajl-dev \
libzmq3-dev \
checkinstall \
gobject-introspection \
libgirepository1.0-dev \
ninja-build \
pkg-config \
python-dev \
python3-dev \
ruby \
ruby-dev \
swig3.0 \
systemd \
libsystemd-dev \
gawk \
lcov \
valgrind && \
rm -rf /var/lib/apt/lists/*
tclcl-dev \
valgrind \
&& rm -rf /var/lib/apt/lists/*

# Google Test
ENV GTEST_ROOT=/opt/gtest
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker/debian/sid/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ RUN mkdir -p ${GTEST_ROOT} \
&& rm gtest.tar.gz

# Prettier
RUN npm install --global prettier@1.16.4
RUN npm install --global prettier@1.18.2

# hyperfine
ARG HYPERFINE_VERSION=1.5.0
Expand Down
26 changes: 12 additions & 14 deletions src/tools/qt-gui/qml/ErrorDialogCreator.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
//display an error message dialog

function showMessage(title, text, detailedText, parent) {
var dialog = null;
var component = Qt.createComponent("ErrorDialog.qml");
var properties = {};

var dialog = null
var component = Qt.createComponent("ErrorDialog.qml")
var properties = {}
properties.title = title;
properties.errorText = text;
properties.detailedText = detailedText;
properties.visible = true;

properties.title = title
properties.errorText = text
properties.detailedText = detailedText
properties.visible = true
dialog = component.createObject(null, properties);

dialog = component.createObject(null, properties)
if (dialog === null)
console.error("error creating errordialog: " + component.errorString());

if (dialog === null)
console.error("error creating errordialog: " + component.errorString())

error = true
return dialog
error = true;
return dialog;
}

14 changes: 6 additions & 8 deletions src/tools/qt-gui/qml/HelperFunctions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
function useIcon (name)
{
if (!guiSettings.useSystemIconTheme) return "";
return name;
function useIcon(name) {
if (!guiSettings.useSystemIconTheme) return "";
return name;
}

function useIconSource (name)
{
if (!guiSettings.useSystemIconTheme) return "icons/".concat (name, ".png");
return "image://theme/".concat (name);
function useIconSource(name) {
if (!guiSettings.useSystemIconTheme) return "icons/".concat(name, ".png");
return "image://theme/".concat(name);
}
Loading

0 comments on commit 8d138a2

Please sign in to comment.