Skip to content

Commit f9baee8

Browse files
chore: migrate to eslint-config-webpack (#201)
1 parent 865b874 commit f9baee8

26 files changed

+17142
-1497
lines changed

.eslintignore

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

.eslintrc.js

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

declarations/ValidationError.d.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ export type PostFormatter = import("./validate").PostFormatter;
88
export type SchemaUtilErrorObject = import("./validate").SchemaUtilErrorObject;
99
declare class ValidationError extends Error {
1010
/**
11-
* @param {Array<SchemaUtilErrorObject>} errors
12-
* @param {Schema} schema
13-
* @param {ValidationErrorConfiguration} configuration
11+
* @param {Array<SchemaUtilErrorObject>} errors array of error objects
12+
* @param {Schema} schema schema
13+
* @param {ValidationErrorConfiguration} configuration configuration
1414
*/
1515
constructor(
1616
errors: Array<SchemaUtilErrorObject>,
1717
schema: Schema,
18-
configuration?: ValidationErrorConfiguration
18+
configuration?: ValidationErrorConfiguration,
1919
);
2020
/** @type {Array<SchemaUtilErrorObject>} */
2121
errors: Array<SchemaUtilErrorObject>;
@@ -28,47 +28,47 @@ declare class ValidationError extends Error {
2828
/** @type {PostFormatter | null} */
2929
postFormatter: PostFormatter | null;
3030
/**
31-
* @param {string} path
32-
* @returns {Schema}
31+
* @param {string} path path
32+
* @returns {Schema} schema
3333
*/
3434
getSchemaPart(path: string): Schema;
3535
/**
36-
* @param {Schema} schema
37-
* @param {boolean} logic
38-
* @param {Array<Object>} prevSchemas
39-
* @returns {string}
36+
* @param {Schema} schema schema
37+
* @param {boolean} logic logic
38+
* @param {Array<object>} prevSchemas prev schemas
39+
* @returns {string} formatted schema
4040
*/
4141
formatSchema(
4242
schema: Schema,
4343
logic?: boolean,
44-
prevSchemas?: Array<Object>
44+
prevSchemas?: Array<object>,
4545
): string;
4646
/**
47-
* @param {Schema=} schemaPart
48-
* @param {(boolean | Array<string>)=} additionalPath
49-
* @param {boolean=} needDot
50-
* @param {boolean=} logic
51-
* @returns {string}
47+
* @param {Schema=} schemaPart schema part
48+
* @param {(boolean | Array<string>)=} additionalPath additional path
49+
* @param {boolean=} needDot true when need dot
50+
* @param {boolean=} logic logic
51+
* @returns {string} schema part text
5252
*/
5353
getSchemaPartText(
5454
schemaPart?: Schema | undefined,
5555
additionalPath?: (boolean | Array<string>) | undefined,
5656
needDot?: boolean | undefined,
57-
logic?: boolean | undefined
57+
logic?: boolean | undefined,
5858
): string;
5959
/**
60-
* @param {Schema=} schemaPart
61-
* @returns {string}
60+
* @param {Schema=} schemaPart schema part
61+
* @returns {string} schema part description
6262
*/
6363
getSchemaPartDescription(schemaPart?: Schema | undefined): string;
6464
/**
65-
* @param {SchemaUtilErrorObject} error
66-
* @returns {string}
65+
* @param {SchemaUtilErrorObject} error error object
66+
* @returns {string} formatted error object
6767
*/
6868
formatValidationError(error: SchemaUtilErrorObject): string;
6969
/**
70-
* @param {Array<SchemaUtilErrorObject>} errors
71-
* @returns {string}
70+
* @param {Array<SchemaUtilErrorObject>} errors errors
71+
* @returns {string} formatted errors
7272
*/
7373
formatValidationErrors(errors: Array<SchemaUtilErrorObject>): string;
7474
}

declarations/keywords/absolutePath.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ export type SchemaValidateFunction = import("ajv").SchemaValidateFunction;
44
export type AnySchemaObject = import("ajv").AnySchemaObject;
55
export type SchemaUtilErrorObject = import("../validate").SchemaUtilErrorObject;
66
/**
7-
*
8-
* @param {Ajv} ajv
9-
* @returns {Ajv}
7+
* @param {Ajv} ajv ajv
8+
* @returns {Ajv} configured ajv
109
*/
1110
declare function addAbsolutePathKeyword(ajv: Ajv): Ajv;

declarations/keywords/limit.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type KeywordErrorDefinition = import("ajv").KeywordErrorDefinition;
88
/** @typedef {import("ajv").Name} Name */
99
/** @typedef {import("ajv").KeywordErrorDefinition} KeywordErrorDefinition */
1010
/**
11-
* @param {Ajv} ajv
12-
* @returns {Ajv}
11+
* @param {Ajv} ajv ajv
12+
* @returns {Ajv} ajv with limit keyword
1313
*/
1414
declare function addLimitKeyword(ajv: Ajv): Ajv;

declarations/keywords/undefinedAsNull.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ export type ValidateFunction = import("ajv").ValidateFunction;
88
/** @typedef {import("ajv").AnySchemaObject} AnySchemaObject */
99
/** @typedef {import("ajv").ValidateFunction} ValidateFunction */
1010
/**
11-
*
12-
* @param {Ajv} ajv
13-
* @returns {Ajv}
11+
* @param {Ajv} ajv ajv
12+
* @returns {Ajv} configured ajv
1413
*/
1514
declare function addUndefinedAsNullKeyword(ajv: Ajv): Ajv;

declarations/util/Range.d.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ export = Range;
99
*/
1010
declare class Range {
1111
/**
12-
* @param {"left" | "right"} side
13-
* @param {boolean} exclusive
14-
* @returns {">" | ">=" | "<" | "<="}
12+
* @param {"left" | "right"} side side
13+
* @param {boolean} exclusive exclusive
14+
* @returns {">" | ">=" | "<" | "<="} operator
1515
*/
1616
static getOperator(
1717
side: "left" | "right",
18-
exclusive: boolean
18+
exclusive: boolean,
1919
): ">" | ">=" | "<" | "<=";
2020
/**
21-
* @param {number} value
21+
* @param {number} value value
2222
* @param {boolean} logic is not logic applied
2323
* @param {boolean} exclusive is range exclusive
24-
* @returns {string}
24+
* @returns {string} formatted right
2525
*/
2626
static formatRight(value: number, logic: boolean, exclusive: boolean): string;
2727
/**
28-
* @param {number} value
28+
* @param {number} value value
2929
* @param {boolean} logic is not logic applied
3030
* @param {boolean} exclusive is range exclusive
31-
* @returns {string}
31+
* @returns {string} formatted left
3232
*/
3333
static formatLeft(value: number, logic: boolean, exclusive: boolean): string;
3434
/**
@@ -37,38 +37,38 @@ declare class Range {
3737
* @param {boolean} startExclusive is range exclusive from left side
3838
* @param {boolean} endExclusive is range exclusive from right side
3939
* @param {boolean} logic is not logic applied
40-
* @returns {string}
40+
* @returns {string} formatted range
4141
*/
4242
static formatRange(
4343
start: number,
4444
end: number,
4545
startExclusive: boolean,
4646
endExclusive: boolean,
47-
logic: boolean
47+
logic: boolean,
4848
): string;
4949
/**
50-
* @param {Array<RangeValue>} values
50+
* @param {Array<RangeValue>} values values
5151
* @param {boolean} logic is not logic applied
52-
* @return {RangeValue} computed value and it's exclusive flag
52+
* @returns {RangeValue} computed value and it's exclusive flag
5353
*/
5454
static getRangeValue(values: Array<RangeValue>, logic: boolean): RangeValue;
5555
/** @type {Array<RangeValue>} */
5656
_left: Array<RangeValue>;
5757
/** @type {Array<RangeValue>} */
5858
_right: Array<RangeValue>;
5959
/**
60-
* @param {number} value
61-
* @param {boolean=} exclusive
60+
* @param {number} value value
61+
* @param {boolean=} exclusive true when exclusive, otherwise false
6262
*/
6363
left(value: number, exclusive?: boolean | undefined): void;
6464
/**
65-
* @param {number} value
66-
* @param {boolean=} exclusive
65+
* @param {number} value value
66+
* @param {boolean=} exclusive true when exclusive, otherwise false
6767
*/
6868
right(value: number, exclusive?: boolean | undefined): void;
6969
/**
7070
* @param {boolean} logic is not logic applied
71-
* @return {string} "smart" range string representation
71+
* @returns {string} "smart" range string representation
7272
*/
7373
format(logic?: boolean): string;
7474
}

declarations/util/memorize.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
export default memoize;
2+
export type FunctionReturning<T> = () => T;
23
/**
34
* @template T
4-
* @param fn {(function(): any) | undefined}
5-
* @returns {function(): T}
5+
* @typedef {() => T} FunctionReturning
66
*/
7-
declare function memoize<T>(fn: (() => any) | undefined): () => T;
7+
/**
8+
* @template T
9+
* @param {FunctionReturning<T>} fn memorized function
10+
* @returns {FunctionReturning<T>} new function
11+
*/
12+
declare function memoize<T>(fn: FunctionReturning<T>): FunctionReturning<T>;

declarations/validate.d.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1+
export { default as ValidationError } from "./ValidationError";
12
export type JSONSchema4 = import("json-schema").JSONSchema4;
23
export type JSONSchema6 = import("json-schema").JSONSchema6;
34
export type JSONSchema7 = import("json-schema").JSONSchema7;
45
export type ErrorObject = import("ajv").ErrorObject;
56
export type ExtendedSchema = {
7+
/**
8+
* format minimum
9+
*/
610
formatMinimum?: (string | number) | undefined;
11+
/**
12+
* format maximum
13+
*/
714
formatMaximum?: (string | number) | undefined;
15+
/**
16+
* format exclusive minimum
17+
*/
818
formatExclusiveMinimum?: (string | boolean) | undefined;
19+
/**
20+
* format exclusive maximum
21+
*/
922
formatExclusiveMaximum?: (string | boolean) | undefined;
23+
/**
24+
* link
25+
*/
1026
link?: string | undefined;
27+
/**
28+
* undefined will be resolved as null
29+
*/
1130
undefinedAsNull?: boolean | undefined;
1231
};
1332
export type Extend = ExtendedSchema;
@@ -17,26 +36,42 @@ export type SchemaUtilErrorObject = ErrorObject & {
1736
};
1837
export type PostFormatter = (
1938
formattedError: string,
20-
error: SchemaUtilErrorObject
39+
error: SchemaUtilErrorObject,
2140
) => string;
2241
export type ValidationErrorConfiguration = {
42+
/**
43+
* name
44+
*/
2345
name?: string | undefined;
46+
/**
47+
* base data path
48+
*/
2449
baseDataPath?: string | undefined;
50+
/**
51+
* post formatter
52+
*/
2553
postFormatter?: PostFormatter | undefined;
2654
};
2755
/**
28-
* @param {Schema} schema
29-
* @param {Array<object> | object} options
30-
* @param {ValidationErrorConfiguration=} configuration
56+
* @param {Schema} schema schema
57+
* @param {Array<object> | object} options options
58+
* @param {ValidationErrorConfiguration=} configuration configuration
3159
* @returns {void}
3260
*/
3361
export function validate(
3462
schema: Schema,
3563
options: Array<object> | object,
36-
configuration?: ValidationErrorConfiguration | undefined
64+
configuration?: ValidationErrorConfiguration | undefined,
3765
): void;
66+
/**
67+
* @returns {void}
68+
*/
3869
export function enableValidation(): void;
70+
/**
71+
* @returns {void}
72+
*/
3973
export function disableValidation(): void;
74+
/**
75+
* @returns {boolean} true when need validate, otherwise false
76+
*/
4077
export function needValidate(): boolean;
41-
import ValidationError from "./ValidationError";
42-
export { ValidationError };

eslint.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from "eslint/config";
2+
import configs from "eslint-config-webpack/configs.js";
3+
4+
export default defineConfig([
5+
{
6+
extends: [configs["recommended-dirty"]],
7+
rules: {
8+
"n/prefer-node-protocol": "off",
9+
},
10+
},
11+
]);

0 commit comments

Comments
 (0)