Skip to content

Commit 4b46b85

Browse files
authored
chore(code-style): run prettier (#1705)
1 parent 113cb46 commit 4b46b85

14 files changed

+114
-120
lines changed

.eslintrc.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
module.exports = {
2-
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
2+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
33
parserOptions: {
44
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
5-
sourceType: "module", // Allows for the use of imports
5+
sourceType: 'module', // Allows for the use of imports
66
ecmaFeatures: {
77
jsx: true, // Allows for the parsing of JSX
88
},
99
},
1010
settings: {
1111
react: {
12-
version: "detect", // Tells eslint-plugin-react to automatically detect the version of React to use
12+
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
1313
},
1414
},
1515
extends: [
16-
"plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
17-
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
16+
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
17+
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
1818
// "prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
1919
// "plugin:prettier/recommended", // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
2020
],
2121
rules: {
2222
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
23-
"@typescript-eslint/explicit-function-return-type": "off",
24-
"react/prop-types": "off"
23+
'@typescript-eslint/explicit-function-return-type': 'off',
24+
'react/prop-types': 'off',
2525
},
2626
};

.prettierignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ dist/
22
ws-messages/
33
package-lock.json
44
package.json
5-
.vscode/
5+
.vscode/
6+
src/i18n/locales/

.release-it.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"git": {
3-
"commitMessage": "chore(deploy): release v${version}"
4-
},
5-
"npm": false
6-
}
2+
"git": {
3+
"commitMessage": "chore(deploy): release v${version}"
4+
},
5+
"npm": false
6+
}

commitlint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = { extends: ["@commitlint/config-conventional"] };
1+
module.exports = { extends: ['@commitlint/config-conventional'] };

i18n-z2m-exporter.js

+15-22
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
const { devices } = require('zigbee-herdsman-converters');
2-
const settingsSchema = require('../zigbee2mqtt/lib/util/settings.schema.json')
2+
const settingsSchema = require('../zigbee2mqtt/lib/util/settings.schema.json');
33
const fs = require('fs');
4-
const camelCase = require("lodash/camelCase");
5-
const startCase = require("lodash/startCase");
6-
4+
const camelCase = require('lodash/camelCase');
5+
const startCase = require('lodash/startCase');
76

87
let featureDescriptions = {};
98
let featureNames = {};
@@ -12,45 +11,39 @@ const exportDescriptions = ({ features = [], description, name }) => {
1211
featureNames[name] = startCase(camelCase(name));
1312
featureDescriptions[description] = description;
1413
if (Array.isArray(features)) {
15-
features.forEach(exportDescriptions)
14+
features.forEach(exportDescriptions);
1615
} else {
17-
features().forEach(exportDescriptions)
16+
features().forEach(exportDescriptions);
1817
}
19-
}
18+
};
2019

21-
devices.forEach(device => {
22-
exportDescriptions({ features: device.exposes })
23-
})
20+
devices.forEach((device) => {
21+
exportDescriptions({ features: device.exposes });
22+
});
2423
const enTranslationFile = './src/i18n/locales/en.json';
2524
const enTranslations = require(enTranslationFile);
2625
enTranslations.featureDescriptions = featureDescriptions;
2726
enTranslations.featureNames = featureNames;
2827

29-
30-
31-
3228
let settingsSchemaDescriptions = {};
3329
let settingsSchemaTitles = {};
34-
const isObject = (value) => value !== null && typeof value === 'object'
30+
const isObject = (value) => value !== null && typeof value === 'object';
3531

3632
const exportSettingsSchemaDescriptions = (obj) => {
3733
Object.entries(obj).forEach(([key, value]) => {
38-
3934
if (isObject(value)) {
40-
exportSettingsSchemaDescriptions(value)
35+
exportSettingsSchemaDescriptions(value);
4136
} else if (key === 'description') {
4237
settingsSchemaDescriptions[value] = value;
4338
} else if (key === 'title') {
4439
settingsSchemaTitles[value] = value;
4540
}
46-
})
47-
}
48-
49-
exportSettingsSchemaDescriptions(settingsSchema)
41+
});
42+
};
5043

44+
exportSettingsSchemaDescriptions(settingsSchema);
5145

5246
enTranslations.settingsSchemaDescriptions = settingsSchemaDescriptions;
5347
enTranslations.settingsSchemaTitles = settingsSchemaTitles;
5448

55-
56-
fs.writeFileSync(enTranslationFile, JSON.stringify(enTranslations, null, 4));
49+
fs.writeFileSync(enTranslationFile, JSON.stringify(enTranslations, null, 4));

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const path = require("path");
1+
const path = require('path');
22

33
module.exports = {
4-
getPath: () => path.join(__dirname, "dist"),
4+
getPath: () => path.join(__dirname, 'dist'),
55
};

renovate.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": [
4-
"config:base"
5-
]
3+
"extends": ["config:base"]
64
}

src/components/extensions-editor/example-extension.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ class MyExampleExtension_TS_ {
99
}
1010

1111
async onStateChange(data) {
12-
console.log("State changed", data); // comment this out if clutters logs
13-
12+
console.log('State changed', data); // comment this out if clutters logs
13+
1414
const { entity, update } = data;
15-
16-
15+
1716
//example how to toggle state
18-
if (entity.ID === '0x00158d000224154d') { //state changed for some device (example: clicked a button)
17+
if (entity.ID === '0x00158d000224154d') {
18+
//state changed for some device (example: clicked a button)
1919
if (update.action === 'single') {
2020
const myLampIeeAddr = '0x00124b001e73227f'; // change this
21-
this.mqtt.onMessage(`${this.mqttBaseTopic}/${myLampIeeAddr}/set`, JSON.stringify({state: 'toggle'}));
21+
this.mqtt.onMessage(`${this.mqttBaseTopic}/${myLampIeeAddr}/set`, JSON.stringify({ state: 'toggle' }));
2222
}
2323
}
2424
}

src/components/settings/uiSchema.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
{
22
"mqtt": {
3-
"ui:order": ["base_topic", "server", "user", "password", "client_id", "version",
4-
"ca", "key", "cert", "reject_unauthorized", "*"]
3+
"ui:order": [
4+
"base_topic",
5+
"server",
6+
"user",
7+
"password",
8+
"client_id",
9+
"version",
10+
"ca",
11+
"key",
12+
"cert",
13+
"reject_unauthorized",
14+
"*"
15+
]
516
},
617
"serial": {
718
"ui:order": ["port", "adapter", "disable_led", "*"]

src/initialState.json

+29-30
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
{
2-
"devices": {},
3-
"deviceStates": {},
4-
"touchlinkDevices": [],
5-
"touchlinkScanInProgress": false,
6-
"touchlinkIdentifyInProgress": false,
7-
"touchlinkResetInProgress": false,
8-
"networkGraph": {
9-
"links": [],
10-
"nodes": []
11-
},
12-
"networkGraphIsLoading": false,
13-
"groups": [],
14-
"bridgeState": "online",
15-
"bridgeConfig": {
16-
},
17-
"bridgeInfo": {
18-
"configSchema": {
19-
"properties": {},
20-
"required": []
2+
"devices": {},
3+
"deviceStates": {},
4+
"touchlinkDevices": [],
5+
"touchlinkScanInProgress": false,
6+
"touchlinkIdentifyInProgress": false,
7+
"touchlinkResetInProgress": false,
8+
"networkGraph": {
9+
"links": [],
10+
"nodes": []
2111
},
22-
"config": {
23-
"advanced": {}
24-
}
25-
},
26-
"logs": [],
27-
"extensions": [],
28-
"theme": "light",
29-
"missingTranslations": {},
30-
"availability": {},
31-
"prepearingBackup": false,
32-
"backup": ""
12+
"networkGraphIsLoading": false,
13+
"groups": [],
14+
"bridgeState": "online",
15+
"bridgeConfig": {},
16+
"bridgeInfo": {
17+
"configSchema": {
18+
"properties": {},
19+
"required": []
20+
},
21+
"config": {
22+
"advanced": {}
23+
}
24+
},
25+
"logs": [],
26+
"extensions": [],
27+
"theme": "light",
28+
"missingTranslations": {},
29+
"availability": {},
30+
"prepearingBackup": false,
31+
"backup": ""
3332
}

trim-locales.js

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,45 @@
1-
2-
var diff = require('deep-diff')
1+
var diff = require('deep-diff');
32
const _ = require('lodash');
4-
const fs = require('fs')
3+
const fs = require('fs');
54

6-
let isObject = function(a) {
7-
return (!!a) && (a.constructor === Object);
5+
let isObject = function (a) {
6+
return !!a && a.constructor === Object;
87
};
98
function removeEmpty(obj) {
109
return Object.entries(obj)
11-
.filter(([_, v]) => v != null && v != "")
12-
.reduce(
13-
(acc, [k, v]) => ({ ...acc, [k]: isObject(v) ? removeEmpty(v) : v }),
14-
{}
15-
);
10+
.filter(([_, v]) => v != null && v != '')
11+
.reduce((acc, [k, v]) => ({ ...acc, [k]: isObject(v) ? removeEmpty(v) : v }), {});
1612
}
1713

1814
const enTranslationFile = './src/i18n/locales/en.json';
1915
const enTranslations = require(enTranslationFile);
2016

21-
2217
const ignoredFiles = ['localeNames.json', 'en.json'];
23-
const localesDir = './src/i18n/locales'
18+
const localesDir = './src/i18n/locales';
2419
const files = [];
25-
const dir = fs.opendirSync(localesDir)
26-
let dirent
20+
const dir = fs.opendirSync(localesDir);
21+
let dirent;
2722
while ((dirent = dir.readSync()) !== null) {
2823
if (!ignoredFiles.includes(dirent.name)) {
29-
files.push(dirent.name)
24+
files.push(dirent.name);
3025
}
3126
}
32-
dir.closeSync()
27+
dir.closeSync();
3328

3429
for (const file of files) {
3530
const localeFileName = `./src/i18n/locales/${file}`;
3631
const translations = require(localeFileName);
37-
const diffR = diff(enTranslations, translations)
32+
const diffR = diff(enTranslations, translations);
3833

3934
let newTranslation = {};
40-
diffR.forEach(d => {
35+
diffR.forEach((d) => {
4136
switch (d.kind) {
4237
case 'E':
4338
_.set(newTranslation, d.path, d.rhs);
4439
break;
4540
}
46-
47-
})
41+
});
4842
newTranslation = removeEmpty(newTranslation);
49-
console.log(`Trimmed ${localeFileName}`)
43+
console.log(`Trimmed ${localeFileName}`);
5044
fs.writeFileSync(localeFileName, JSON.stringify(newTranslation, null, 4));
51-
}
45+
}

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"allowSyntheticDefaultImports": true,
1313
"esModuleInterop": true,
1414
"strictNullChecks": true,
15-
"resolveJsonModule": true,
15+
"resolveJsonModule": true
1616
},
1717
"suppressImplicitAnyIndexErrors": true,
1818
"lib": ["dom", "esnext"],

vite.config.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
3-
import sassDts from "vite-plugin-sass-dts";
3+
import sassDts from 'vite-plugin-sass-dts';
44
import viteCompression from 'vite-plugin-compression';
55
import { startServer } from './ws';
66

@@ -14,7 +14,7 @@ export default defineConfig(async ({ command }) => {
1414
base: '',
1515
build: {
1616
emptyOutDir: true,
17-
outDir: '../dist'
17+
outDir: '../dist',
1818
},
1919
plugins: [
2020
react({
@@ -27,10 +27,10 @@ export default defineConfig(async ({ command }) => {
2727
proxy: {
2828
'/api': {
2929
changeOrigin: true,
30-
target: process.env.Z2M_API_URI ? process.env.Z2M_API_URI : "ws://localhost:8579",
31-
ws: true
32-
}
33-
}
34-
}
35-
}
36-
});
30+
target: process.env.Z2M_API_URI ? process.env.Z2M_API_URI : 'ws://localhost:8579',
31+
ws: true,
32+
},
33+
},
34+
},
35+
};
36+
});

0 commit comments

Comments
 (0)