Skip to content

Prefer Module Scope Constants

Suggestion
small-rules/prefer-module-scope-constants

Prefer screaming snake case constants at module scope or the allowed top-level wrapper scope.

Diagnostic Messages

mustBeModuleScope
You must place screaming snake case at module scope. If this is not meant to be a module-scoped variable, use camelcase instead.
mustUseConst
You must use `const` when defining screaming snake case variables. If this is not a constant, use camelcase instead.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/prefer-module-scope-constants": "error"
}
}

Examples

Function constant at local scope
function foo() { const FOO = true; }
Module-scoped screaming constant
const FOO = true;