Skip to content

Commit 818b239

Browse files
authored
Added JS files formatting with Prettier (#2573)
* Added Prettier and ESlint config * Prettier formatting * Remove obsolete files * [CI] Added CI step * Adjusted code highlighting * Migration from node-sass to sass * Added yarn.lock to gitignore * Bumped version
1 parent 21d66a4 commit 818b239

File tree

18 files changed

+45
-148
lines changed

18 files changed

+45
-148
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/webpack.config.js
2+
vendor

.eslintrc.json

+1-29
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
11
{
2-
"plugins": ["prettier"],
3-
"extends": ["prettier", "eslint:recommended"],
4-
"env": {
5-
"browser": true,
6-
"commonjs": true,
7-
"es6": true,
8-
"node": true
9-
},
10-
"parser": "babel-eslint",
11-
"parserOptions": {
12-
"ecmaFeatures": {
13-
"jsx": true,
14-
"classes": true,
15-
"experimentalObjectRestSpread": true
16-
},
17-
"sourceType": "module"
18-
},
19-
"rules": {
20-
"no-const-assign": "warn",
21-
"no-console": "off",
22-
"no-this-before-super": "warn",
23-
"no-undef": "warn",
24-
"no-unreachable": "warn",
25-
"no-unused-vars": "warn",
26-
"constructor-super": "warn",
27-
"valid-typeof": "warn",
28-
"no-extra-semi": "error",
29-
"no-extra-boolean-cast": "off"
30-
}
2+
"extends": "eslint-config-ibexa/eslint"
313
}

.github/workflows/build.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
- name: Run PHP CS Fixer
3636
run: tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots
3737

38+
- name: Run Prettier
39+
run: |
40+
yarn install
41+
yarn prettier-test --write
42+
3843
- name: Commit changes
3944
uses: stefanzweifel/git-auto-commit-action@v4
4045
with:

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ __pycache__/*
66
.php-cs-fixer.cache
77
composer.lock
88
tools/php-cs-fixer/vendor
9+
node_modules/
10+
.yarn
11+
yarn.lock

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/webpack.config.js

code_samples/back_office/image_editor/assets/random_dot/random-dot-stem.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ ibexa.addConfig(
2929
icon: ibexa.helpers.icon.getIconPath('radio-button'), // Path to an icon that will be displayed in the UI
3030
identifier: IDENTIFIER, // The identifier must match the one from the configuration yaml file
3131
},
32-
true
32+
true,
3333
);

code_samples/back_office/image_editor/assets/random_dot/random-dot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ ibexa.addConfig(
6565
icon: ibexa.helpers.icon.getIconPath('radio-button'),
6666
identifier: IDENTIFIER,
6767
},
68-
true
68+
true,
6969
);

code_samples/back_office/online_editor/assets/js/online_editor/buttons/date.js

-41
This file was deleted.

code_samples/back_office/online_editor/assets/js/online_editor/buttons/hr.js

-48
This file was deleted.

code_samples/back_office/online_editor/assets/js/online_editor/plugins/date.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
const InsertDate = {
77
exec: function (editor) {
88
const now = new Date();
9-
editor.insertHtml( now.toString() );
9+
editor.insertHtml(now.toString());
1010
},
1111
};
12-
12+
1313
global.CKEDITOR.plugins.add('date', {
1414
init: (editor) => editor.addCommand('InsertDate', InsertDate),
1515
});
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
const ibexaConfigManager = require('./ibexa.webpack.config.manager.js');
32

43
ibexaConfigManager.add({
54
ibexaConfig,
65
entryName: 'ibexa-admin-ui-layout-js',
7-
newItems: [ path.resolve(__dirname, './assets/js/admin.search.autocomplete.product.js'), ],
6+
newItems: [path.resolve(__dirname, './assets/js/admin.search.autocomplete.product.js')],
87
});

code_samples/back_office/search/assets/js/admin.search.autocomplete.product.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
(function (global, doc, ibexa, Routing) {
22
const renderItem = (result, searchText) => {
33
const globalSearch = doc.querySelector('.ibexa-global-search');
4-
const {highlightText} = ibexa.helpers.highlight;
5-
const autocompleteHighlightTemplate = globalSearch.querySelector('.ibexa-global-search__autocomplete-list').dataset.templateHighlight;
6-
const {getContentTypeIconUrl, getContentTypeName} = ibexa.helpers.contentType;
4+
const { highlightText } = ibexa.helpers.highlight;
5+
const autocompleteHighlightTemplate = globalSearch.querySelector('.ibexa-global-search__autocomplete-list').dataset
6+
.templateHighlight;
7+
const { getContentTypeIconUrl, getContentTypeName } = ibexa.helpers.contentType;
78

8-
const autocompleteItemTemplate = globalSearch.querySelector('.ibexa-global-search__autocomplete-product-template').dataset.templateItem;
9+
const autocompleteItemTemplate = globalSearch.querySelector('.ibexa-global-search__autocomplete-product-template').dataset
10+
.templateItem;
911

1012
return autocompleteItemTemplate
11-
.replace('{{ productHref }}', Routing.generate('ibexa.product_catalog.product.view', {productCode: result.productCode}))
13+
.replace('{{ productHref }}', Routing.generate('ibexa.product_catalog.product.view', { productCode: result.productCode }))
1214
.replace('{{ productName }}', highlightText(searchText, result.name, autocompleteHighlightTemplate))
1315
.replace('{{ productCode }}', result.productCode)
1416
.replace('{{ productTypeIconHref }}', getContentTypeIconUrl(result.productTypeIdentifier))

code_samples/back_office/udw/assets/js/image-tab/components/image.js

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code_samples/back_office/udw/assets/js/image-tab/image.tab.module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ibexa.addConfig(
2222
icon: '/bundles/ibexaadminui/img/ibexa-icons.svg#image',
2323
},
2424
],
25-
true
25+
true,
2626
);
2727

2828
export default ImageTabModule;

code_samples/forms/custom_form_attribute/assets/js/formbuilder-richtext-checkbox.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@
33
const richtext = new ibexa.BaseRichText();
44

55
// Enable editor in all ibexa-data-source divs
6-
doc.querySelectorAll('.ibexa-data-source').forEach(
7-
(ibexaDataSource) => {
8-
const richtextContainer = ibexaDataSource.querySelector(
9-
'.ibexa-data-source__richtext'
10-
);
6+
doc.querySelectorAll('.ibexa-data-source').forEach((ibexaDataSource) => {
7+
const richtextContainer = ibexaDataSource.querySelector('.ibexa-data-source__richtext');
118

12-
if (richtextContainer.classList.contains('ck')) {
13-
return;
14-
}
15-
16-
richtext.init(richtextContainer);
9+
if (richtextContainer.classList.contains('ck')) {
10+
return;
1711
}
18-
);
12+
13+
richtext.init(richtextContainer);
14+
});
1915
});
2016

2117
const openUdw = (config) => {

code_samples/page/react_app_block/assets/page-builder/react/blocks/Calculator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Calculator from "/assets/page-builder/components/Calculator";
1+
import Calculator from '/assets/page-builder/components/Calculator';
22

33
export default {
44
Calculator: Calculator,

docs/administration/back_office/customize_search_suggestion.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ To allow template override and ease HTML writing, the example is also loading a
110110

111111
Here is a complete `assets/js/admin.search.autocomplete.product.js` from the product suggestion example:
112112

113-
``` js hl_lines="8"
113+
``` js hl_lines="9"
114114
[[= include_file('code_samples/back_office/search/assets/js/admin.search.autocomplete.product.js') =]]
115115
```
116116

package.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
"main": "index.js",
55
"repository": "[email protected]:ibexa/documentation-developer.git",
66
"scripts": {
7-
"scss": "node-sass --watch scss -o docs/css"
7+
"scss": "sass --watch scss:docs/css",
8+
"test": "yarn prettier-test && yarn eslint-test",
9+
"fix": "yarn prettier-test --write && yarn eslint-test --fix",
10+
"eslint-test": "eslint \"./code_samples/**/*.js\"",
11+
"prettier-test": "yarn prettier \"./code_samples/**/*.{js,scss}\" --check"
12+
},
13+
"prettier": "eslint-config-ibexa/prettier",
14+
"devDependencies": {
15+
"eslint-config-ibexa": "https://github.com/ibexa/eslint-config-ibexa.git#~v1.1.1"
816
},
917
"dependencies": {
10-
"node-sass": "^9.0.0"
18+
"sass": "^1.82.0"
1119
}
1220
}

0 commit comments

Comments
 (0)