Skip to content

No .spec File Extension

Error
small-rules/no-spec-file-extension

Disallow the .spec.{ts,tsx} file extension for test files. Use .test.{ts,tsx} instead.

Rationale

Pick one suffix for test files and every tool only needs one pattern: the test runner’s include glob, the editor’s file nesting, the coverage excludes. Having both .spec and .test also means someone has to decide which one each new file gets. The pick here is .test.

It only looks at the file name, and only flags .spec.ts and .spec.tsx.

Diagnostic Messages

noSpecFileExtension
Test files must use .test.ts or .test.tsx instead of .spec.ts or .spec.tsx. Rename this file to use the .test extension.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-spec-file-extension": "error"
}
}

Examples

Spec file extension
export const x = 1;
Test file extension
export const x = 1;