Skip to content

NoJsFileExtensions

const NoJsFileExtensions: object

Defined in: policies/NoJsFileExtensions.ts:12

A repo policy that checks for JavaScript source files that just use the .js file extension. Such files may be interpreted by node as either CommonJS or ESM based on the type field in the nearest package.json file. This can create unexpected behavior for JS files; changing the package.json nearest to one will change how the JS is processed by node. Using explicit file extensions reduces ambiguity and ensures a CJS file isn’t suddenly treated like an ESM file.

description: string = "Prevents ambiguous .js files by requiring explicit .mjs or .cjs extensions based on module format."

handler: () => Operation<PolicyFinding[]>

Operation<PolicyFinding[]>

match: RegExp

name: string = "NoJsFileExtensions"