forked from mysticatea/eslint-plugin-node
-
-
Notifications
You must be signed in to change notification settings - Fork 47
feat: typescript (jsdoc) checking and definition generation #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5284ca0
chore: add some low hanging fruit types
scagood 66d67d5
chore: small steps
scagood 65e5ee3
chore: Simplify check-existence
scagood 4734de9
fix: All types in the utils directory
scagood 617cf2d
fix(prefer-promises): missing TraceMap type
scagood 67342b5
fix(hashbang): Add missing types
scagood 8111d22
fix: Add types for "process-exit-as-throw"
scagood e2cf47e
chore: unifi TraceMap
scagood 51a5a14
feat: Types for lib/rules
scagood 0eb19e1
Update tsconfig.json
aladdin-add a5958e0
ci: Add tsc compile on pack and test
scagood fc9dd91
ci: Export types in package.json
scagood 3103a77
ci: run tests and linting once
scagood 23e9416
chore: Remove all "{Object}" from "@typedef"
scagood ab7b4b7
fix: Remove typecast infavour of union a discriminator check
scagood 5f99801
chore: Remove more unneed casting
scagood c56a18a
fix: Better types from JSON.parse
scagood 90d9181
chore: 1 typedef per doc comment
scagood b3fccf9
fix: dont cast ErrnoException
scagood 45009d3
feat: better "TraceMap" types
scagood 5ea136a
chore: Add comment for the "ts-expect-error"
scagood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ | |
/test.js | ||
.eslintcache | ||
.vscode | ||
.idea/ | ||
.idea/ | ||
|
||
types/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,19 @@ | ||
"use strict" | ||
|
||
module.exports = { | ||
commonRules: { | ||
"n/no-deprecated-api": "error", | ||
"n/no-extraneous-import": "error", | ||
"n/no-extraneous-require": "error", | ||
"n/no-exports-assign": "error", | ||
"n/no-missing-import": "error", | ||
"n/no-missing-require": "error", | ||
"n/no-process-exit": "error", | ||
"n/no-unpublished-bin": "error", | ||
"n/no-unpublished-import": "error", | ||
"n/no-unpublished-require": "error", | ||
"n/no-unsupported-features/es-builtins": "error", | ||
"n/no-unsupported-features/es-syntax": "error", | ||
"n/no-unsupported-features/node-builtins": "error", | ||
"n/process-exit-as-throw": "error", | ||
"n/hashbang": "error", | ||
}, | ||
} | ||
module.exports.commonRules = /** @type {const} */ ({ | ||
"n/no-deprecated-api": "error", | ||
"n/no-extraneous-import": "error", | ||
"n/no-extraneous-require": "error", | ||
"n/no-exports-assign": "error", | ||
"n/no-missing-import": "error", | ||
"n/no-missing-require": "error", | ||
"n/no-process-exit": "error", | ||
"n/no-unpublished-bin": "error", | ||
"n/no-unpublished-import": "error", | ||
"n/no-unpublished-require": "error", | ||
"n/no-unsupported-features/es-builtins": "error", | ||
"n/no-unsupported-features/es-syntax": "error", | ||
"n/no-unsupported-features/node-builtins": "error", | ||
"n/process-exit-as-throw": "error", | ||
"n/hashbang": "error", | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
declare module "eslint-plugin-es-x" { | ||
export const rules: NonNullable<import('eslint').ESLint.Plugin["rules"]>; | ||
} | ||
|
||
declare module "@eslint-community/eslint-utils" { | ||
scagood marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import * as estree from 'estree'; | ||
import * as eslint from 'eslint'; | ||
|
||
type Node = estree.Node | estree.Expression; | ||
|
||
export const READ: unique symbol; | ||
export const CALL: unique symbol; | ||
export const CONSTRUCT: unique symbol; | ||
export const ESM: unique symbol; | ||
export class ReferenceTracker { | ||
constructor(globalScope: eslint.Scope.Scope, { mode, globalObjectNames, }?: { | ||
mode?: "legacy" | "strict" | undefined; | ||
globalObjectNames?: string[] | undefined; | ||
} | undefined); | ||
variableStack: eslint.Scope.Variable[]; | ||
globalScope: eslint.Scope.Scope; | ||
mode: "legacy" | "strict"; | ||
globalObjectNames: string[]; | ||
iterateGlobalReferences<Info extends unknown>(traceMap: TraceMap<Info>): IterableIterator<Reference<Info>>; | ||
iterateCjsReferences<Info extends unknown>(traceMap: TraceMap<Info>): IterableIterator<Reference<Info>>; | ||
iterateEsmReferences<Info extends unknown>(traceMap: TraceMap<Info>): IterableIterator<Reference<Info>>; | ||
} | ||
export namespace ReferenceTracker { | ||
export { READ }; | ||
export { CALL }; | ||
export { CONSTRUCT }; | ||
export { ESM }; | ||
} | ||
type ReferenceType = typeof READ | typeof CALL | typeof CONSTRUCT; | ||
type TraceMap<Info extends unknown> = { | ||
[READ]?: Info; | ||
[CALL]?: Info; | ||
[CONSTRUCT]?: Info; | ||
[key: string]: TraceMap<Info>; | ||
} | ||
type RichNode = eslint.Rule.Node | Node; | ||
type Reference<Info extends unknown> = { | ||
node: RichNode; | ||
path: string[]; | ||
type: ReferenceType; | ||
info: Info; | ||
}; | ||
|
||
export function findVariable(initialScope: eslint.Scope.Scope, nameOrNode: string | Node): eslint.Scope.Variable | null; | ||
|
||
export function getFunctionHeadLocation(node: Extract<eslint.Rule.Node, { | ||
type: 'FunctionDeclaration' | 'FunctionExpression' | 'ArrowFunctionExpression'; | ||
}>, sourceCode: eslint.SourceCode): eslint.AST.SourceLocation | null; | ||
|
||
export function getFunctionNameWithKind(node: Extract<eslint.Rule.Node, { | ||
type: 'FunctionDeclaration' | 'FunctionExpression' | 'ArrowFunctionExpression'; | ||
}>, sourceCode?: eslint.SourceCode | undefined): string; | ||
|
||
export function getInnermostScope(initialScope: eslint.Scope.Scope, node: Node): eslint.Scope.Scope; | ||
|
||
export function getPropertyName(node: Extract<Node, { | ||
type: 'MemberExpression' | 'Property' | 'MethodDefinition' | 'PropertyDefinition'; | ||
}>, initialScope?: eslint.Scope.Scope | undefined): string | null; | ||
|
||
export function getStaticValue(node: Node, initialScope?: eslint.Scope.Scope | null | undefined): { | ||
value: unknown; | ||
optional?: never; | ||
} | { | ||
value: undefined; | ||
optional?: true; | ||
} | null; | ||
|
||
export function getStringIfConstant(node: Node, initialScope?: eslint.Scope.Scope | null | undefined): string | null; | ||
|
||
export function hasSideEffect(node: eslint.Rule.Node, sourceCode: eslint.SourceCode, { considerGetters, considerImplicitTypeConversion }?: VisitOptions | undefined): boolean; | ||
type VisitOptions = { | ||
considerGetters?: boolean | undefined; | ||
considerImplicitTypeConversion?: boolean | undefined; | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.