Skip to content

Commit 41058f9

Browse files
committed
Update eslint dependencies and lint project.
1 parent 0dc77db commit 41058f9

3 files changed

Lines changed: 53 additions & 18 deletions

File tree

eslint.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import eslint from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
4+
export default tseslint.config(
5+
{
6+
ignores: ['dist/**'],
7+
},
8+
{
9+
rules: {
10+
'quotes': ['error', 'single'],
11+
'indent': ['error', 2, { 'SwitchCase': 0 }],
12+
'linebreak-style': ['error', 'unix'],
13+
'semi': ['error', 'always'],
14+
'comma-dangle': ['error', 'always-multiline'],
15+
'dot-notation': 'error',
16+
'eqeqeq': ['error', 'smart'],
17+
'curly': ['error', 'all'],
18+
'brace-style': ['error'],
19+
'prefer-arrow-callback': 'warn',
20+
'max-len': ['warn', 160],
21+
'object-curly-spacing': ['error', 'always'],
22+
'no-use-before-define': 'off',
23+
'@typescript-eslint/no-use-before-define': ['error', { 'classes': false, 'enums': false }],
24+
'@typescript-eslint/no-unused-vars': ['error', { 'caughtErrors': 'none' }],
25+
},
26+
},
27+
{
28+
languageOptions: {
29+
ecmaVersion: 2022,
30+
sourceType: 'module',
31+
},
32+
},
33+
eslint.configs.recommended,
34+
...tseslint.configs.recommended,
35+
);

src/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export interface Sensor {
1717
TC_TYPE?: string; // undocumented thermocouple probe type
1818
}
1919

20+
export const formatErrorMessage = (errorMessage: string, errorContext?: string): string => {
21+
return `${errorContext ? errorContext : ''} Report the following response in our issue tracker: ` +
22+
'https://github.com/gorhack/tempstick/issues\n' +
23+
`${errorMessage}`;
24+
};
25+
2026
export const requestTempStickApi = async (apiUrl: string, apiKey: string) => {
2127
// https://tempstickapi.com/docs/ v1.0.0
2228
// returns the `data` from the requested API
@@ -29,7 +35,7 @@ export const requestTempStickApi = async (apiUrl: string, apiKey: string) => {
2935
const headers = new Headers();
3036
headers.append('X-API-KEY', apiKey);
3137
headers.append('Content-Type', 'text/plain');
32-
const res = await fetch(apiUrl, {headers: headers});
38+
const res = await fetch(apiUrl, { headers: headers });
3339
if (res.status !== 200) {
3440
// catch all non-200 error codes (400, 500, etc)
3541
throw new Error(formatErrorMessage(JSON.stringify(res),
@@ -45,9 +51,3 @@ export const requestTempStickApi = async (apiUrl: string, apiKey: string) => {
4551
}
4652
return jsonData.data;
4753
};
48-
49-
export const formatErrorMessage = (errorMessage: string, errorContext?: string): string => {
50-
return `${errorContext ? errorContext : ''} Report the following response in our issue tracker: ` +
51-
'https://github.com/gorhack/tempstick/issues\n' +
52-
`${errorMessage}`;
53-
};

tsconfig.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
22
"compilerOptions": {
3-
"allowSyntheticDefaultImports": true,
4-
"declaration": true,
5-
"esModuleInterop": true,
6-
"forceConsistentCasingInFileNames": true,
7-
"outDir": "dist",
8-
"rootDir": "src",
3+
"target": "ES2022",
94
"lib": [
105
"DOM",
116
"ES2022"
127
],
8+
"rootDir": "src",
139
"module": "ES2022",
14-
"moduleResolution":"node",
15-
"sourceMap": true,
10+
"moduleResolution": "node",
1611
"strict": true,
17-
"target": "ES2022"
12+
"declaration": true,
13+
"outDir": "dist",
14+
"sourceMap": true,
15+
"allowSyntheticDefaultImports": true,
16+
"esModuleInterop": true,
17+
"forceConsistentCasingInFileNames": true
1818
},
1919
"include": [
20-
"eslint.config.mjs",
20+
"eslint.config.js",
2121
"homebridge-ui",
2222
"src"
2323
]
24-
}
24+
}

0 commit comments

Comments
 (0)