Skip to content

Commit 44fc449

Browse files
Lite 29719 update eslint config and add prettier (#66)
* LITE-29719 update eslintrc, add prettier config, add github action for prettier * LITE-29719 run prettier to format all files * LITE-29719 remove not needed script
1 parent 1da8d18 commit 44fc449

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+857
-875
lines changed

.eslintrc.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require('@rushstack/eslint-patch/modern-module-resolution');
2+
13
module.exports = {
24
root: true,
35

@@ -13,6 +15,8 @@ module.exports = {
1315
'plugin:vue/vue3-recommended',
1416
'eslint:recommended',
1517
'plugin:storybook/recommended',
18+
'prettier',
19+
'@vue/eslint-config-prettier/skip-formatting',
1620
],
1721

1822
plugins: ['vue'],
@@ -21,17 +25,21 @@ module.exports = {
2125
rules: {
2226
'vue/multi-word-component-names': 'off',
2327
'vue/no-deprecated-slot-attribute': 'off',
28+
'vue/block-order': [
29+
'error',
30+
{
31+
order: ['template', 'script', 'style'],
32+
},
33+
],
34+
'vue/attribute-hyphenation': ['error', 'never'],
2435
},
2536

2637
overrides: [
2738
// Config for unit tests
2839
{
2940
files: ['*.spec.js'],
3041
plugins: ['jest'],
31-
extends: [
32-
'plugin:jest/recommended',
33-
'plugin:jest-formatting/strict',
34-
],
42+
extends: ['plugin:jest/recommended', 'plugin:jest-formatting/strict'],
3543
env: {
3644
jest: true,
3745
'jest/globals': true,

.github/workflows/build.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ name: Build and Test
22

33
on:
44
push:
5-
branches: "*"
5+
branches: '*'
66
tags:
77
- '*'
88

99
pull_request:
10-
branches: [ master ]
10+
branches: [master]
1111

1212
jobs:
1313
test:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
node: [ '18', '20' ]
17+
node: ['18', '20']
1818
name: Node ${{ matrix.node }}
1919
steps:
2020
- name: Checkout
@@ -24,9 +24,11 @@ jobs:
2424
with:
2525
node-version: ${{ matrix.node }}
2626
- name: Install dependencies
27-
run: npm install
27+
run: npm ci
2828
- name: Lint
2929
run: npm run lint
30+
- name: Check formatting with Prettier
31+
run: npm run format:check
3032
- name: Testing
3133
run: npm test
3234
sonar:
@@ -41,7 +43,7 @@ jobs:
4143
with:
4244
node-version: 20
4345
- name: Install dependencies
44-
run: npm install
46+
run: npm ci
4547
- name: Testing
4648
run: npm test
4749
- uses: SonarSource/sonarcloud-github-action@master

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
node-version: 20
1919
- name: Install dependencies
20-
run: npm install
20+
run: npm ci
2121
- name: Build
2222
run: npm run build
2323
- name: Testing
@@ -26,6 +26,6 @@ jobs:
2626
uses: JS-DevTools/npm-publish@v3
2727
with:
2828
token: ${{ secrets.NPM_TOKEN }}
29-
access: "public"
29+
access: 'public'
3030
dry-run: false
3131
strategy: all

.prettierrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json.schemastore.org/prettierrc",
3+
"semi": true,
4+
"tabWidth": 2,
5+
"useTabs": false,
6+
"singleQuote": true,
7+
"printWidth": 100,
8+
"trailingComma": "all",
9+
"singleAttributePerLine": true
10+
}

.storybook/CloudBlueTheme.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
21
import { create } from '@storybook/theming';
32

43
export default create({
54
base: 'light',
65
brandTitle: 'CloudBlue Connect',
76
brandUrl: 'https://connect.cloudblue.com',
8-
brandImage: 'https://connect.cloudblue.com/wp-content/uploads/2020/07/ClouBlue-Standalone-Logo-Blue.png',
7+
brandImage:
8+
'https://connect.cloudblue.com/wp-content/uploads/2020/07/ClouBlue-Standalone-Logo-Blue.png',
99
brandTarget: '_self',
1010
});
11-

.storybook/main.js

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
const path = require('node:path');
22

3-
43
module.exports = {
54
stories: [
6-
"../components/src/**/*.stories.@(js|jsx|ts|tsx|vue)",
7-
"../components/src/stories/**/*.mdx",
5+
'../components/src/**/*.stories.@(js|jsx|ts|tsx|vue)',
6+
'../components/src/stories/**/*.mdx',
87
],
98

10-
staticDirs: ["../public"],
9+
staticDirs: ['../public'],
1110

1211
addons: [
13-
"@storybook/addon-links",
14-
"@storybook/addon-essentials",
15-
"@storybook/addon-interactions",
16-
"@storybook/addon-designs",
17-
"storybook-vue-addon",
18-
"storybook-addon-vue-mdx",
12+
'@storybook/addon-links',
13+
'@storybook/addon-essentials',
14+
'@storybook/addon-interactions',
15+
'@storybook/addon-designs',
16+
'storybook-vue-addon',
17+
'storybook-addon-vue-mdx',
1918
],
2019

2120
framework: {
22-
name: "@storybook/vue3-webpack5",
21+
name: '@storybook/vue3-webpack5',
2322
options: {},
2423
},
2524

@@ -28,38 +27,32 @@ module.exports = {
2827
},
2928

3029
webpackFinal: async (config) => {
31-
config.module.rules.push(
32-
{
33-
test: /\.svg/,
34-
type: 'asset/source',
35-
loader: 'svgo-loader',
36-
options: {
37-
configFile: require.resolve('../components/svgo.config.js'),
38-
},
39-
}
40-
);
30+
config.module.rules.push({
31+
test: /\.svg/,
32+
type: 'asset/source',
33+
loader: 'svgo-loader',
34+
options: {
35+
configFile: require.resolve('../components/svgo.config.js'),
36+
},
37+
});
4138

4239
// Find Vue webpack rule and update its options to work with custom elements
43-
const vueRule = config.module.rules.find(rule => rule.test?.toString() === '/\\.vue$/');
40+
const vueRule = config.module.rules.find((rule) => rule.test?.toString() === '/\\.vue$/');
4441
vueRule.options = {
4542
...vueRule.options,
4643
customElement: true,
4744
compilerOptions: {
48-
isCustomElement: tag => tag.startsWith('ui-'),
45+
isCustomElement: (tag) => tag.startsWith('ui-'),
4946
},
5047
};
5148

5249
config.module.rules.push({
5350
test: /\.styl(us)$/,
54-
use: [
55-
'vue-style-loader',
56-
'css-loader',
57-
'stylus-loader',
58-
],
51+
use: ['vue-style-loader', 'css-loader', 'stylus-loader'],
5952
});
6053

6154
config.resolve.alias = {
62-
'vue': path.resolve(__dirname, '../node_modules/vue/dist/vue.esm-bundler.js'),
55+
vue: path.resolve(__dirname, '../node_modules/vue/dist/vue.esm-bundler.js'),
6356
'~core': path.resolve(__dirname, '../components/src/core'),
6457
'~widgets': path.resolve(__dirname, '../components/src/widgets'),
6558
'~constants': path.resolve(__dirname, '../components/src/constants'),

.storybook/manager.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { addons } from '@storybook/addons';
32
import { themes } from '@storybook/theming';
43
import cloudBlueTheme from './CloudBlueTheme';

.storybook/preview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const parameters = {
2-
actions: { argTypesRegex: "^on[A-Z].*" },
2+
actions: { argTypesRegex: '^on[A-Z].*' },
33
controls: {
44
matchers: {
55
color: /(background|color)$/i,
66
date: /Date$/,
77
},
88
},
9-
}
9+
};

README.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,39 @@
77

88
---
99

10-
Build your Connect Extension UI easily with our UI Toolkit. Feel free to use any frontend library
10+
Build your Connect Extension UI easily with our UI Toolkit. Feel free to use any frontend library
1111
or framework you prefer!
1212

1313
## Installation
14+
1415
### Minimalistic via CDN
1516

1617
Just plug a module via `script` tag, import default exported function and call it. You're good.
1718

1819
N.B.: For development mode - by default `<path>` will be `http://localhost:3003`
1920

2021
```html
21-
<script type="module">
22+
<script type="module">
2223
import createApp from '<path>';
23-
24+
2425
createApp();
2526
</script>
2627
```
2728

2829
This will implement minimalistic interaction with parent Connect Application.
2930

3031
## Usage
32+
3133
### Use widgets
3234

3335
1. Import required widget from named exports
3436
2. Pass a configuration Object to `createApp` function as an argument
3537
3. Configuration object should contain desired tag name as a `key` and widget descriptor object as a `value`. N.B.: widget name should contain at least one "-"
3638

3739
```html
38-
<script type="module">
39-
import createApp, {
40-
Card,
41-
} from '<path>';
42-
40+
<script type="module">
41+
import createApp, { Card } from '<path>';
42+
4343
createApp({
4444
'my-card': Card,
4545
});
@@ -55,24 +55,26 @@ This will implement minimalistic interaction with parent Connect Application.
5555
Control widgets using attributes (see widgets documentation)
5656

5757
### Interaction with parent app
58-
We implemented two ways to interact with parent application - one is data-based, another events-based.
59-
You will find supported data properties and handled events list in slot's documentation.
60-
Let's see how you can use it to build your app:
58+
59+
We implemented two ways to interact with parent application - one is data-based, another events-based.
60+
You will find supported data properties and handled events list in slot's documentation.
61+
Let's see how you can use it to build your app:
6162

6263
### Data-based interface with `watch/commit`
63-
If some data-based interface is documented for particular slot
64+
65+
If some data-based interface is documented for particular slot
6466
you may subscribe on it using `watch` method or publish changes using `commit`
6567

6668
```html
67-
<script type="module">
69+
<script type="module">
6870
import createApp from '<path>';
69-
71+
7072
const app = createApp();
71-
72-
app.watch('observed', (value) => {
73+
74+
app.watch('observed', (value) => {
7375
/* handle "observed" property change here */
7476
});
75-
77+
7678
app.commit({
7779
observed: /* Desired "observed" value here */,
7880
});
@@ -94,29 +96,18 @@ Functions, Dates etc. will not work.**
9496
### Events-based interface with `listen/emit`;
9597

9698
```html
97-
<script type="module">
99+
<script type="module">
98100
import createApp from '<path>';
99-
101+
100102
const app = createApp();
101-
103+
102104
app.emit('openDialog', {
103105
title: 'Lorem Ipsum',
104106
description: 'Dolor sit amet',
105107
});
106-
108+
107109
app.listen('dialog:confirmed', () => {
108110
/* handle parent app dialog confirmation */
109111
});
110112
</script>
111113
```
112-
113-
114-
115-
116-
117-
118-
119-
120-
121-
122-

components/babel.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module.exports = {
2-
"presets": [
3-
"@vue/cli-plugin-babel/preset",
4-
],
2+
presets: ['@vue/cli-plugin-babel/preset'],
53
};

0 commit comments

Comments
 (0)