NoJsFileExtensions
constNoJsFileExtensions: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.
Type Declaration
Section titled “Type Declaration”description
Section titled “description”description:
string="Prevents ambiguous .js files by requiring explicit .mjs or .cjs extensions based on module format."
handler
Section titled “handler”handler: () =>
Operation<PolicyFinding[]>
Returns
Section titled “Returns”Operation<PolicyFinding[]>
match:
RegExp
name:
string="NoJsFileExtensions"