Skip to content

Commit 0ab68e4

Browse files
committed
use nullish coalescing operator where possible
1 parent 11a8381 commit 0ab68e4

21 files changed

+137
-126
lines changed

js/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ module.exports = {
7777
'unicorn/no-negated-condition': 'off',
7878
'unicorn/no-null': 'off',
7979
'unicorn/no-this-assignment': 'off',
80-
'unicorn/prefer-logical-operator-over-ternary': 'off', // nullish coalescing operator has limited support
8180
'unicorn/prefer-module': 'off',
8281
'unicorn/prevent-abbreviations': 'off',
8382
'unicorn/switch-case-braces': ['error', 'avoid'],

js/babel.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ module.exports = (api) => {
55
return {
66
presets: [
77
[
8-
'@babel/env',
8+
'@babel/preset-env',
99
{
10-
targets: '> 1%, not dead',
10+
targets: 'defaults',
1111
corejs: { version: '3.9999', proposals: true },
1212
useBuiltIns: 'usage',
1313
},

js/src/plugins/ajaxec.plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export default class AtkAjaxecPlugin extends AtkPlugin {
2222

2323
doExecute() {
2424
const url = atk.urlHelper.removeAllParams(this.settings.url);
25-
const userConfig = this.settings.apiConfig ? this.settings.apiConfig : {};
25+
const userConfig = this.settings.apiConfig ?? {};
2626

2727
// urlOptions is always used as data in a POST request
28-
const data = this.settings.urlOptions ? this.settings.urlOptions : {};
28+
const data = this.settings.urlOptions ?? {};
2929

3030
// retrieve param from URL
3131
let urlParams = atk.urlHelper.parseParams(this.settings.url);

js/src/plugins/reload-view.plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ export default class AtkReloadViewPlugin extends AtkPlugin {
2121
}
2222

2323
const url = atk.urlHelper.removeAllParams(this.settings.url);
24-
const userConfig = this.settings.apiConfig ? this.settings.apiConfig : {};
24+
const userConfig = this.settings.apiConfig ?? {};
2525

2626
// add new param and remove duplicate, prioritizing the latest one.
2727
let urlParams = Object.assign(
2828
atk.urlHelper.parseParams(this.settings.url),
29-
this.settings.urlOptions ? this.settings.urlOptions : {}
29+
this.settings.urlOptions ?? {}
3030
);
3131

3232
// get store object.

js/src/services/modal.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class ModalService {
9292

9393
const $content = $modal.find('.atk-dialog-content');
9494

95-
$content.html(this.getLoaderHtml(data.loadingLabel ? data.loadingLabel : ''));
95+
$content.html(this.getLoaderHtml(data.loadingLabel ?? ''));
9696

9797
$content.api({
9898
on: 'now',

js/src/services/panel.service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class PanelService {
8181
openPanel(params) {
8282
// if no id is provide, then get the first one.
8383
// no id mean the first panel in list.
84-
const panelId = (params.openId) ? params.openId : Object.keys(this.service.panels[0])[0];
84+
const panelId = params.openId ?? Object.keys(this.service.panels[0])[0];
8585
// save our open param.
8686
this.service.currentParams = params;
8787
if (this.isSameElement(panelId, params.triggered)) {

js/src/vue-components/multiline/multiline-body.component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default {
3838
return this.deletables.includes(row.__atkml);
3939
},
4040
getRowErrors: function (rowId) {
41-
return this.errors[rowId] ? this.errors[rowId] : [];
41+
return this.errors[rowId] ?? [];
4242
},
4343
},
4444
};

js/src/vue-components/multiline/multiline.component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default {
7272
AtkMultilineBody: multilineBody,
7373
},
7474
mounted: function () {
75-
this.rowData = this.buildRowData(this.valueJson ? this.valueJson : '[]');
75+
this.rowData = this.buildRowData(this.valueJson ?? '[]');
7676
this.updateInputValue();
7777

7878
atk.eventBus.on(this.$root.$el.parentElement.id + '-update-row', (payload) => {

js/src/vue-components/query-builder/query-builder.component.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ export default {
5454
},
5555
data: function () {
5656
return {
57-
query: this.data.query ? this.data.query : {},
58-
rules: this.data.rules ? this.data.rules : [],
59-
name: this.data.name ? this.data.name : '',
60-
maxDepth: this.data.maxDepth ? this.data.maxDepth : 1,
57+
query: this.data.query ?? {},
58+
rules: this.data.rules ?? [],
59+
name: this.data.name ?? '',
60+
maxDepth: this.data.maxDepth ?? 1,
6161
labels: this.getLabels(this.data.labels),
6262
form: this.data.form,
63-
debug: this.data.debug ? this.data.debug : false,
63+
debug: this.data.debug ?? false,
6464
};
6565
},
6666
computed: {

public/js/atk-vue-multiline.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/atk-vue-multiline.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)