-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: add missing type definitions #246
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
/** DON'T EDIT THIS FILE WHICH WAS CREATED BY 'scripts/generate-index.js'. */ | ||
"use strict" | ||
|
||
const rules = require("./lib/rules") | ||
const utils = require("./lib/utils") | ||
const configs = require("./lib/configs") | ||
|
||
module.exports = { | ||
configs: require("./lib/configs"), | ||
rules: require("./lib/rules"), | ||
utils: require("./lib/utils"), | ||
configs, | ||
rules, | ||
utils, | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||||||||||||||||||||
import configs = require("@eslint-community/eslint-plugin-eslint-comments/configs") | ||||||||||||||||||||||
import expectTypeModule = require("expect-type") | ||||||||||||||||||||||
|
||||||||||||||||||||||
import type { Linter } from "eslint" | ||||||||||||||||||||||
|
||||||||||||||||||||||
import expectTypeOf = expectTypeModule.expectTypeOf | ||||||||||||||||||||||
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should most of this not be
Suggested change
I have never seen this syntax before, so do correct me if I am wrong 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this file I'm testing the types to make sure they work with TypeScript's CJS syntax. So something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, neat! Thanks for the explanation :) Edit: I can't seem to mark this as resolved 👀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @scagood It might be good to fully migrate to TypeScript so the types and runtime code don't get out of sync. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the previous discussion in the That being said, that is more a question for @eslint-community/eslint-plugin-eslint-comments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I see, honestly I would be happy to do it, I've done a lot of TS migrations and I could definitely do this one too. We can bundle with |
||||||||||||||||||||||
|
||||||||||||||||||||||
expectTypeOf(configs) | ||||||||||||||||||||||
.toHaveProperty("recommended") | ||||||||||||||||||||||
.toMatchTypeOf<Linter.FlatConfig>() | ||||||||||||||||||||||
|
||||||||||||||||||||||
expectTypeOf([configs.recommended]).toMatchTypeOf<Linter.FlatConfig[]>() | ||||||||||||||||||||||
|
||||||||||||||||||||||
expectTypeOf(configs.recommended).toMatchTypeOf<Linter.FlatConfig>() | ||||||||||||||||||||||
|
||||||||||||||||||||||
expectTypeOf(configs) | ||||||||||||||||||||||
.toHaveProperty("recommended") | ||||||||||||||||||||||
.toMatchTypeOf<Linter.FlatConfig>() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import configs from "@eslint-community/eslint-plugin-eslint-comments/configs" | ||
import type { Linter } from "eslint" | ||
import { expectTypeOf } from "expect-type" | ||
|
||
expectTypeOf(configs) | ||
.toHaveProperty("recommended") | ||
.toMatchTypeOf<Linter.FlatConfig>() | ||
|
||
expectTypeOf([configs.recommended]).toMatchTypeOf<Linter.FlatConfig[]>() | ||
|
||
expectTypeOf(configs.recommended).toMatchTypeOf<Linter.FlatConfig>() | ||
|
||
expectTypeOf(configs) | ||
.toHaveProperty("recommended") | ||
.toMatchTypeOf<Linter.FlatConfig>() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": false, | ||
"esModuleInterop": false, | ||
"forceConsistentCasingInFileNames": true, | ||
"isolatedModules": true, | ||
"lib": ["ESNext"], | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"noEmit": true, | ||
"resolveJsonModule": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"target": "ESNext", | ||
"useDefineForClassFields": true, | ||
"useUnknownInCatchVariables": true, | ||
"verbatimModuleSyntax": true | ||
}, | ||
"include": ["."] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Linter } from "eslint" | ||
|
||
declare namespace Configs { | ||
import defaultExports = Configs | ||
|
||
export const recommended: Linter.FlatConfig | ||
|
||
export { defaultExports as default } | ||
} | ||
|
||
export = Configs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { ESLint, Linter } from "eslint" | ||
|
||
export declare const configs: { recommended: Linter.FlatConfig } | ||
|
||
export declare const rules: NonNullable<ESLint.Plugin["rules"]> | ||
|
||
export declare const utils: { patch: (ruleId?: string) => void } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have
configs
types defined, so I don't think it's necessary to declare them again intypesVersions
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it
Node10
module resolution will fail when importing from@eslint-community/eslint-plugin-eslint-comments/configs
.