Skip to content

Commit 4778127

Browse files
committed
chore: update eslint rules
1 parent cb5841c commit 4778127

8 files changed

Lines changed: 480 additions & 670 deletions

File tree

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

eslint.config.js

Lines changed: 59 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,63 @@
11
// @ts-check
2-
import { dirname } from 'node:path';
3-
import { fileURLToPath } from 'node:url';
2+
import stylisticJs from '@stylistic/eslint-plugin';
43

54
import importPlugin from 'eslint-plugin-import';
65
import tseslint from 'typescript-eslint';
76

87
export default tseslint.config(
98
...tseslint.configs.recommendedTypeChecked,
9+
...tseslint.configs.stylistic,
10+
{
11+
ignores: [
12+
'.gitignore',
13+
'example',
14+
'*.json',
15+
'dist'
16+
]
17+
},
1018
{
1119
languageOptions: {
12-
ecmaVersion: 2022,
13-
sourceType: 'module',
1420
parserOptions: {
15-
project: true,
16-
tsconfigRootDir: dirname( fileURLToPath( import.meta.url ) ),
21+
project: 'tsconfig.eslint.json',
22+
tsconfigRootDir: import.meta.dirname,
1723
},
1824
},
1925
plugins: {
20-
import: importPlugin,
26+
import: importPlugin,
27+
'@style': stylisticJs,
2128
},
2229
rules: {
23-
'@typescript-eslint/ban-ts-ignore': 'off',
24-
'@typescript-eslint/explicit-function-return-type': [ 'error' ],
25-
'@typescript-eslint/explicit-module-boundary-types': [ 'error' ],
26-
'@typescript-eslint/indent': [ 'error', 2, {
27-
ArrayExpression: 'first',
30+
'@style/indent': ['error', 2, {
31+
ArrayExpression: 'first',
2832
FunctionDeclaration: {
2933
parameters: 'first'
3034
},
31-
ImportDeclaration: 1,
32-
ObjectExpression: 1,
33-
SwitchCase: 1,
35+
ImportDeclaration: 1,
36+
ObjectExpression: 1,
37+
SwitchCase: 1,
3438
VariableDeclarator: 'first'
35-
} ],
36-
'@typescript-eslint/no-unsafe-argument': 'off',
37-
'@typescript-eslint/no-unsafe-call': 'off',
38-
'@typescript-eslint/no-unsafe-return': 'off',
39+
}],
40+
'@style/no-extra-parens': ['error'],
41+
'@style/type-annotation-spacing': 'error',
42+
'@typescript-eslint/ban-ts-ignore': 'off',
43+
'@typescript-eslint/explicit-function-return-type': ['error'],
44+
'@typescript-eslint/explicit-module-boundary-types': ['error'],
45+
'@typescript-eslint/interface-name-prefix': 'off',
46+
'@typescript-eslint/no-explicit-any': 'off',
3947
'@typescript-eslint/no-redundant-type-constituents': 'off',
40-
'@typescript-eslint/no-unsafe-assignment': 'off',
41-
'@typescript-eslint/no-unsafe-member-access': 'off',
42-
'@typescript-eslint/interface-name-prefix': 'off',
43-
'@typescript-eslint/no-explicit-any': 'off',
44-
'@typescript-eslint/no-extra-parens': [ 'error' ],
48+
'@typescript-eslint/no-unsafe-argument': 'off',
49+
'@typescript-eslint/no-unsafe-assignment': 'off',
50+
'@typescript-eslint/no-unsafe-call': 'off',
51+
'@typescript-eslint/no-unsafe-member-access': 'off',
52+
'@typescript-eslint/no-unsafe-return': 'off',
53+
'@typescript-eslint/prefer-promise-reject-errors': 'off',
4554
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
46-
'@typescript-eslint/type-annotation-spacing': 'error',
47-
'array-bracket-spacing': 'error',
48-
'comma-spacing': [ 2, { before: false, after: true } ],
49-
'computed-property-spacing': [ 'error', 'never', { enforceForClassMembers: true } ],
50-
'import/first': 'error',
51-
'import/no-useless-path-segments': [
55+
'array-bracket-spacing': 'error',
56+
'comma-spacing': [2, { before: false, after: true }],
57+
'computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
58+
'import/first': 'error',
59+
'import/no-duplicates': 'error',
60+
'import/no-useless-path-segments': [
5261
'error',
5362
{
5463
noUselessIndex: true
@@ -58,44 +67,43 @@ export default tseslint.config(
5867
'error',
5968
{
6069
'newlines-between': 'always-and-inside-groups',
61-
'alphabetize': {
62-
order: 'asc',
70+
'alphabetize': {
71+
order: 'asc',
6372
caseInsensitive: true
6473
},
6574
'pathGroups': [
6675
{
6776
pattern: '~/**',
68-
group: 'external'
77+
group: 'external'
6978
}
7079
]
7180
}
7281
],
73-
'indent': 'off',
74-
'key-spacing': [ 'error', { align: 'value' } ],
75-
'keyword-spacing': [ 'error' ],
82+
'indent': 'off',
83+
'key-spacing': ['error', { align: 'value' }],
84+
'keyword-spacing': ['error'],
7685
'linebreak-style': [
7786
'error',
7887
'unix'
7988
],
80-
'lines-between-class-members': [ 'error', 'always' ],
81-
'no-debugger': 'error',
82-
'no-extra-parens': 'off',
83-
'no-mixed-spaces-and-tabs': 'error',
84-
'no-multi-spaces': [ 'error', { exceptions: { VariableDeclarator: true } } ],
85-
'no-var': 'error',
86-
'import/no-duplicates': 'error',
89+
'lines-between-class-members': ['error', 'always'],
90+
'no-debugger': 'error',
91+
'no-extra-parens': 'off',
92+
'no-mixed-spaces-and-tabs': 'error',
93+
'no-multi-spaces': ['error', { exceptions: { VariableDeclarator: true } }],
94+
'no-var': 'error',
8795
'no-whitespace-before-property': 'error',
88-
'object-curly-spacing': [
96+
'object-curly-spacing': [
8997
'error',
9098
'always',
9199
{
92-
arraysInObjects: true,
100+
arraysInObjects: true,
93101
objectsInObjects: true
94102
}
95103
],
96-
'padded-blocks': [ 'error', 'never' ],
104+
'padded-blocks': ['error', 'never'],
97105
'prefer-template': 'error',
98-
'quotes': [
106+
'quotes': [
99107
'error',
100108
'single',
101109
{
@@ -105,13 +113,13 @@ export default tseslint.config(
105113
'space-before-function-paren': [
106114
'error',
107115
{
108-
anonymous: 'always',
116+
anonymous: 'always',
109117
asyncArrow: 'always',
110-
named: 'never'
118+
named: 'never'
111119
}
112120
],
113-
'space-in-parens': [ 'error', 'always' ],
114-
'template-curly-spacing': [ 'error', 'always' ]
121+
'space-in-parens': ['error', 'always'],
122+
'template-curly-spacing': ['error', 'always']
115123
}
116124
}
117125
);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"@commitlint/config-conventional": "^19.4.1",
4040
"@microsoft/api-extractor": "^7.47.7",
4141
"@release-it/conventional-changelog": "^8.0.1",
42+
"@stylistic/eslint-plugin": "^2.8.0",
4243
"@swc/core": "^1.7.24",
4344
"eslint": "^9.10.0",
4445
"eslint-plugin-import": "^2.30.0",

src/http.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class HttpService {
9292
}
9393
try {
9494
new URL( apiURL );
95-
} catch ( e ) {
95+
} catch {
9696
throw new Error( '\'apiUrl\' must be a valid uri' );
9797
}
9898

@@ -130,9 +130,9 @@ export class HttpService {
130130
}
131131
};
132132
if ( args.length > 1 ) {
133-
method !== 'get' ?
134-
fetchOptions.body = typeof args[1] === 'object' ? JSON.stringify( args[1] ) : args[1]
135-
: null;
133+
if ( method !== 'get' ) {
134+
fetchOptions.body = typeof args[1] === 'object' ? JSON.stringify( args[1] ) : args[1];
135+
}
136136
}
137137
if ( !!args[2] && typeof args[2] === 'object' ) {
138138
fetchOptions = deepmerge( fetchOptions, args[2] );

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import {
1515
LogService, ProviderService
1616
} from './api';
1717

18-
type Options = {
18+
interface Options {
1919
httpClient?: ( uri: string, options: RequestInit ) => Promise<any>
2020
token?: string | ( () => string )
2121
version?: string
22-
};
22+
}
2323

2424
/**
2525
*

0 commit comments

Comments
 (0)