Skip to content

Commit 2c4c5b3

Browse files
committed
style: eslint fixes
1 parent c477d25 commit 2c4c5b3

File tree

6 files changed

+52
-24
lines changed

6 files changed

+52
-24
lines changed

eslint.config.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ import typescriptEslint from "typescript-eslint"
66

77
export default typescriptEslint.config(
88
{
9-
ignores: ["*.d.ts", "**/coverage", "**/dist", "assets/"],
9+
ignores: [
10+
"*.d.ts",
11+
"**/coverage",
12+
"**/dist",
13+
"assets/",
14+
"src/dev.ts",
15+
"tests/components/*",
16+
],
1017
extends: [
1118
eslint.configs.recommended,
1219
...typescriptEslint.configs.recommended,
@@ -21,6 +28,15 @@ export default typescriptEslint.config(
2128
},
2229
rules: {
2330
"@typescript-eslint/no-explicit-any": "off", // Allow the use of `any`
31+
"@typescript-eslint/no-unused-vars": [
32+
"error",
33+
{
34+
args: "all",
35+
argsIgnorePattern: "^_",
36+
varsIgnorePattern: "^_",
37+
caughtErrorsIgnorePattern: "^_",
38+
},
39+
],
2440
"vue/multi-word-component-names": "off", // Disable multi-word component names rule
2541
"vue/require-default-prop": "off", // Disable requiring default props
2642
"vue/no-v-html": "off", // Allow v-html usage (if needed)

src/aliases.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function delAliases(keys: string[]): void {
4343
}
4444

4545
function isAlias(key: string): boolean {
46-
return Object(aliases).hasOwnProperty(key)
46+
return Object.prototype.hasOwnProperty.call(aliases, key)
4747
}
4848

4949
function getAlias(key: string): FieldAlias {

src/parser/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ import {
88
toTitleCase,
99
} from "../helpers"
1010
import { ProviderService } from "../provider"
11+
import {
12+
type Attribute,
13+
type ComponentProvider,
14+
type Field,
15+
type FieldDescription,
16+
type FieldType,
17+
type FieldValue,
18+
type ParserOptions,
19+
type VueComponent,
20+
type VueComponentProps,
21+
} from "../types"
1122

1223
const defaultParserOptions: ParserOptions = {
1324
attachRandomId: true,
@@ -82,7 +93,7 @@ export class Parser {
8293
return field.componentFeedback || "vfb-feedback"
8394
}
8495

85-
getFieldFeedbackComponentProps(field: Field): VueComponentProps {
96+
getFieldFeedbackComponentProps(_field: Field): VueComponentProps {
8697
return {
8798
validFeedbackComponent: this.components["feedbackValid"],
8899
invalidFeedbackComponent: this.components["feedbackInvalid"],
@@ -141,7 +152,7 @@ export class Parser {
141152
const attributeObject: Attribute = this.stringToAttribute(attrStr)
142153
for (const key in attributeObject) {
143154
const attributeValue: any = attributeObject[key]
144-
if (!Object(field).hasOwnProperty(key))
155+
if (!Object.prototype.hasOwnProperty.call(field, key))
145156
field[key] = attributeValue
146157
else field[key] = { ...field[key], ...attributeValue }
147158
}

src/provider/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const providers: Providers = {
1313
}
1414

1515
function addProvider(name: ProviderName, provider: ComponentProvider) {
16-
if (!Object(providers).hasOwnProperty(name)) providers[name] = provider
16+
if (!Object.prototype.hasOwnProperty.call(providers, name))
17+
providers[name] = provider
1718
}
1819

1920
function delProvider(name: ProviderName) {
@@ -25,7 +26,7 @@ function getProvider(name: ProviderName) {
2526
}
2627

2728
function hasProvider(name: ProviderName) {
28-
return Object(providers).hasOwnProperty(name)
29+
return Object.prototype.hasOwnProperty.call(providers, name)
2930
}
3031

3132
function setProvider(name: ProviderName, provider: ComponentProvider) {

src/provider/providers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ type CP = ComponentProvider
8989
function addMissingComponentsToProvider(source: CP, target: CP) {
9090
// Copy components from source to target if they are not present in target.
9191
for (const fieldType of Object.keys(source)) {
92-
if (!Object(target).hasOwnProperty(fieldType)) {
92+
if (!Object.prototype.hasOwnProperty.call(target, fieldType)) {
9393
target[fieldType] = source[fieldType]
9494
}
9595
}

src/types.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// TYPE DEFINITIONS
22

3-
type VueComponent = string
4-
type VueComponentProps = { [key: string]: any }
3+
export type VueComponent = string
4+
export type VueComponentProps = { [key: string]: any }
55

6-
type FieldValue = any
7-
type FieldType = string
8-
type FieldName = string
9-
type Field = {
6+
export type FieldValue = any
7+
export type FieldType = string
8+
export type FieldName = string
9+
export type Field = {
1010
[index: string]: any
1111
component: VueComponent
1212
componentFeedback: VueComponent
@@ -22,24 +22,24 @@ type Field = {
2222
wrapper?: VueComponent
2323
}
2424

25-
type FieldDescription = Field | string | any
26-
type FieldAlias = FieldDescription
27-
type FieldAliases = { [key: string]: FieldAlias }
25+
export type FieldDescription = Field | string | any
26+
export type FieldAlias = FieldDescription
27+
export type FieldAliases = { [key: string]: FieldAlias }
2828

29-
type Attribute = { [key: string]: any }
30-
interface AttributeParser {
29+
export type Attribute = { [key: string]: any }
30+
export interface AttributeParser {
3131
isAttribute(str: string): boolean
3232
stringToAttribute(str: string): Attribute
3333
}
3434

35-
type Data = { [key: FieldName]: FieldValue }
36-
type Model = { [key: FieldName]: FieldValue }
35+
export type Data = { [key: FieldName]: FieldValue }
36+
export type Model = { [key: FieldName]: FieldValue }
3737

38-
type ComponentProvider = { [key: FieldType]: VueComponent }
39-
type ProviderName = string
40-
type Providers = { [key: ProviderName]: ComponentProvider }
38+
export type ComponentProvider = { [key: FieldType]: VueComponent }
39+
export type ProviderName = string
40+
export type Providers = { [key: ProviderName]: ComponentProvider }
4141

42-
type ParserOptions = {
42+
export type ParserOptions = {
4343
attachRandomId?: boolean
4444
provider: ProviderName
4545
wrapper?: VueComponent

0 commit comments

Comments
 (0)