Skip to content

Commit

Permalink
Refactor tsconfig for Stricter Type-Safe Settings (#605)
Browse files Browse the repository at this point in the history
* refactor: update tsconfig for type-safe improvements

* fix: revert plugin configs

* fix: Remove unused import
  • Loading branch information
y-hsgw authored Dec 20, 2024
1 parent 448650c commit 949aaf7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ESLint, Linter } from 'eslint'
import type { Linter } from 'eslint'
import { version } from '../package.json'
import lowerCaseTitle, { RULE_NAME as lowerCaseTitleName } from './rules/prefer-lowercase-title'
import maxNestedDescribe, { RULE_NAME as maxNestedDescribeName } from './rules/max-nested-describe'
Expand Down Expand Up @@ -233,15 +233,15 @@ const plugin = {
'legacy-all': createConfigLegacy(allRules),
'recommended': {
plugins: {
get vitest(): ESLint.Plugin {
get vitest() {
return plugin
}
},
rules: createConfig(recommended)
},
'all': {
plugins: {
get vitest(): ESLint.Plugin {
get vitest() {
return plugin
}
},
Expand Down Expand Up @@ -292,6 +292,6 @@ const plugin = {
}
}
}
} satisfies ESLint.Plugin
}

export default plugin
3 changes: 1 addition & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
KnownMemberExpression,
ParsedExpectVitestFnCall
} from './parse-vitest-fn-call'
import { Rule } from 'eslint'

interface PluginDocs {
recommended?: boolean
Expand All @@ -23,7 +22,7 @@ export function createEslintRule<TOptions extends readonly unknown[], TMessageId
`https://github.com/vitest-dev/eslint-plugin-vitest/blob/main/docs/rules/${ruleName}.md`
)

return createRule(rule) as unknown as Rule.RuleModule
return createRule(rule)
}

export const joinNames = (a: string | null, b: string | null): string | null =>
Expand Down
20 changes: 10 additions & 10 deletions tests/expect-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ it('example', async () => {
},
{
code: 'afterEach(() => {});',
options: [{ additionalTestBlockFunctions: ['afterEach'] }],
options: [{ additionalTestBlockFunctions: ['afterEach'], assertFunctionNames: [] }],
errors: [
{
messageId: 'noAssertions',
Expand All @@ -97,7 +97,7 @@ it('example', async () => {
const output = NumberToLongString(theory.input);
})
`,
options: [{ additionalTestBlockFunctions: ['theoretically'] }],
options: [{ additionalTestBlockFunctions: ['theoretically'], assertFunctionNames: [] }],
errors: [
{
messageId: 'noAssertions',
Expand All @@ -116,7 +116,7 @@ it('example', async () => {
},
{
code: 'test("should fail", () => { foo(true).toBe(true); })',
options: [{ assertFunctionNames: ['expect'] }],
options: [{ assertFunctionNames: ['expect'], additionalTestBlockFunctions: [] }],
errors: [
{
messageId: 'noAssertions',
Expand All @@ -126,7 +126,7 @@ it('example', async () => {
},
{
code: 'it("should also fail",() => expectSaga(mySaga).returns());',
options: [{ assertFunctionNames: ['expect'] }],
options: [{ assertFunctionNames: ['expect'], additionalTestBlockFunctions: [] }],
errors: [
{
messageId: 'noAssertions',
Expand All @@ -136,7 +136,7 @@ it('example', async () => {
},
{
code: 'test(\'should fail\', () => request.get().foo().expect(456));',
options: [{ assertFunctionNames: ['request.*.expect'] }],
options: [{ assertFunctionNames: ['request.*.expect'], additionalTestBlockFunctions: [] }],
errors: [
{
messageId: 'noAssertions',
Expand All @@ -146,7 +146,7 @@ it('example', async () => {
},
{
code: 'test(\'should fail\', () => request.get().foo().bar().expect(456));',
options: [{ assertFunctionNames: ['request.foo**.expect'] }],
options: [{ assertFunctionNames: ['request.foo**.expect'], additionalTestBlockFunctions: [] }],
errors: [
{
messageId: 'noAssertions',
Expand All @@ -156,7 +156,7 @@ it('example', async () => {
},
{
code: 'test(\'should fail\', () => tester.request(123));',
options: [{ assertFunctionNames: ['request.*'] }],
options: [{ assertFunctionNames: ['request.*'], additionalTestBlockFunctions: [] }],
errors: [
{
messageId: 'noAssertions',
Expand All @@ -166,7 +166,7 @@ it('example', async () => {
},
{
code: 'test(\'should fail\', () => request(123));',
options: [{ assertFunctionNames: ['request.*'] }],
options: [{ assertFunctionNames: ['request.*'], additionalTestBlockFunctions: [] }],
errors: [
{
messageId: 'noAssertions',
Expand All @@ -176,7 +176,7 @@ it('example', async () => {
},
{
code: 'test(\'should fail\', () => request(123));',
options: [{ assertFunctionNames: ['request.**'] }],
options: [{ assertFunctionNames: ['request.**'], additionalTestBlockFunctions: [] }],
errors: [
{
messageId: 'noAssertions',
Expand Down Expand Up @@ -244,7 +244,7 @@ it('example', async () => {
// ...
})
`,
options: [{ additionalTestBlockFunctions: ['myExtendedTest'] }],
options: [{ additionalTestBlockFunctions: ['myExtendedTest'], assertFunctionNames: [] }],
languageOptions: { parserOptions: { sourceType: 'module' } },
errors: [
{
Expand Down
21 changes: 11 additions & 10 deletions tests/unbound-method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import unboundMethod from '../src/rules/unbound-method'
const rootPath = path.join(__dirname, './fixtures')

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: rootPath,
project: './tsconfig.json',
sourceType: 'module'
languageOptions: {
parserOptions: {
tsconfigRootDir: rootPath,
project: './tsconfig.json',
sourceType: 'module'
}
}
})

Expand All @@ -20,16 +21,16 @@ ruleTester.run('unbound-method', unboundMethod, {
public logArrowBound = (): void => {
console.log(bound);
};
public logManualBind(): void {
console.log(this);
}
}
const instance = new MyClass();
const logArrowBound = instance.logArrowBound;
const logManualBind = instance.logManualBind.bind(instance);
logArrowBound();
logManualBind();`,
skip: true
Expand All @@ -43,9 +44,9 @@ ruleTester.run('unbound-method', unboundMethod, {
process.stdout.write(str);
}
}
const console = new Console();
Promise.resolve().then(console.log);
`,
skip: true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"skipLibCheck": true,
"strictNullChecks": true
},
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts","tests/**/*.ts"],
}

0 comments on commit 949aaf7

Please sign in to comment.