Skip to content

Commit

Permalink
chore: setup typescript-eslint (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Aug 7, 2024
1 parent 0f0fb92 commit e976d60
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
10 changes: 10 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import eslintConfigESLint from "eslint-config-eslint";
import tseslint from "typescript-eslint";

const eslintPluginJSDoc = eslintConfigESLint.find(
config => config.plugins?.jsdoc,
Expand Down Expand Up @@ -53,4 +54,13 @@ export default [
},
},
},

// TypeScript
...tseslint.config({
files: ["**/*.ts"],
extends: [...tseslint.configs.strict, ...tseslint.configs.stylistic],
rules: {
"no-use-before-define": "off",
},
}),
];
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"got": "^14.4.1",
"lint-staged": "^15.2.0",
"prettier": "^3.1.1",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.0",
"yorkie": "^2.0.0"
}
}
30 changes: 15 additions & 15 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,12 @@ export type SettingsConfig = Record<string, unknown>;
/**
* The configuration for a rule.
*/
export type RuleConfig = Severity | [Severity, ...any[]];
export type RuleConfig = Severity | [Severity, ...unknown[]];

/**
* A collection of rules and their configurations.
*/
export interface RulesConfig {
[ruleId: string]: RuleConfig;
}
export type RulesConfig = Record<string, RuleConfig>;

//------------------------------------------------------------------------------
// Languages
Expand Down Expand Up @@ -162,7 +160,7 @@ export interface Language {
/**
* The traversal path that tools should take when evaluating the AST
*/
visitorKeys?: Record<string, Array<string>>;
visitorKeys?: Record<string, string[]>;

/**
* Validates languageOptions for this language.
Expand All @@ -178,7 +176,7 @@ export interface Language {
matchesSelectorClass?(
className: string,
node: object,
ancestry: Array<object>,
ancestry: object[],
): boolean;

/**
Expand Down Expand Up @@ -259,6 +257,7 @@ export interface OkParseResult<T extends object = object> {
/**
* Any additional data that the parser wants to provide.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687133551
[key: string]: any;
}

Expand All @@ -277,11 +276,12 @@ export interface NotOkParseResult {
/**
* Any parsing errors, whether fatal or not. (only when ok: false)
*/
errors: Array<FileError>;
errors: FileError[];

/**
* Any additional data that the parser wants to provide.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687133551
[key: string]: any;
}

Expand Down Expand Up @@ -320,7 +320,7 @@ interface SourceCodeBase {
* When present, this overrides the `visitorKeys` on the language for
* just this source code object.
*/
visitorKeys?: Record<string, Array<string>>;
visitorKeys?: Record<string, string[]>;

/**
* Retrieves the equivalent of `loc` for a given node or token.
Expand All @@ -347,23 +347,23 @@ interface SourceCodeBase {
* along with any problems found in evaluating the directives.
*/
getDisableDirectives?(): {
directives: Array<Directive>;
problems: Array<FileProblem>;
directives: Directive[];
problems: FileProblem[];
};

/**
* Returns an array of all inline configuration nodes found in the
* source code.
*/
getInlineConfigNodes?(): Array<object>;
getInlineConfigNodes?(): object[];

/**
* Applies configuration found inside of the source code. This method is only
* called when ESLint is running with inline configuration allowed.
*/
applyInlineConfig?(): {
configs: Array<InlineConfigElement>;
problems: Array<FileProblem>;
configs: InlineConfigElement[];
problems: FileProblem[];
};

/**
Expand Down Expand Up @@ -404,7 +404,7 @@ export interface VisitTraversalStep {
kind: 1;
target: object;
phase: 1 /* enter */ | 2 /* exit */;
args: Array<any>;
args: unknown[];
}

/**
Expand All @@ -414,7 +414,7 @@ export interface CallTraversalStep {
kind: 2;
target: string;
phase?: string;
args: Array<any>;
args: unknown[];
}

export type TraversalStep = VisitTraversalStep | CallTraversalStep;
Expand Down
2 changes: 2 additions & 0 deletions packages/object-schema/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ export interface PropertyDefinition {
/**
* The strategy to merge the property.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687206213
merge: BuiltInMergeStrategy | ((target: any, source: any) => any);

/**
* The strategy to validate the property.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687206213
validate: BuiltInValidationStrategy | ((value: any) => void);

/**
Expand Down

0 comments on commit e976d60

Please sign in to comment.