
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
eslint-plugin-variable-naming
Advanced tools
ESLint plugin to enforce consistent variable naming conventions with full configurability
ESLint plugin to enforce consistent variable naming conventions with full configurability.
npm install --save-dev eslint-plugin-variable-naming
.eslintrc.json){
"parser": "@typescript-eslint/parser",
"plugins": ["variable-naming"],
"rules": {
"variable-naming/enforce-variable-naming-convention": ["error", {
"caseType": "camelCase"
}]
}
}
eslint.config.js)const variableNaming = require('eslint-plugin-variable-naming');
const tsParser = require('@typescript-eslint/parser');
module.exports = [{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json',
},
},
plugins: {
'variable-naming': variableNaming,
},
rules: {
'variable-naming/enforce-variable-naming-convention': ['error', {
caseType: 'camelCase',
}],
},
}, ];
eslint.config.ts)import variableNaming from 'eslint-plugin-variable-naming';
import tsParser from '@typescript-eslint/parser';
import type {
Linter
} from 'eslint';
const config: Linter.FlatConfig[] = [{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json',
},
},
plugins: {
'variable-naming': variableNaming,
},
rules: {
'variable-naming/enforce-variable-naming-convention': ['error', {
caseType: 'camelCase',
checkFunctions: false,
ignoreDestructuring: false,
ignoreImports: false,
}],
},
}, ];
export default config;
.eslintrc.json){
"parser": "@typescript-eslint/parser",
"extends": ["plugin:variable-naming/recommended"]
}
const variableNaming = require('eslint-plugin-variable-naming');
const tsParser = require('@typescript-eslint/parser');
module.exports = [{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
project: './tsconfig.json',
},
},
...variableNaming.configs.recommended,
}, ];
import variableNaming from 'eslint-plugin-variable-naming';
import tsParser from '@typescript-eslint/parser';
export default [{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tsParser,
parserOptions: {
project: './tsconfig.json',
},
},
...variableNaming.configs.recommended,
}, ];
// eslint.config.ts
export default [{
files: ['**/*.ts', '**/*.tsx'],
rules: {
'variable-naming/enforce-variable-naming-convention': ['error', {
// Specify the case type
caseType: 'camelCase',
// Allowed patterns (regex) to ignore
allowedPatterns: ['^_.*', '^CONSTANT_.*'],
// TypeScript types to exclude
excludeTypes: ['Promise', 'Observable'],
// React component creator functions
componentCreators: ['lazy', 'memo', 'forwardRef'],
// CSS-in-JS libraries
styledLibraries: ['styled', 'emotion'],
// Hook pattern (null to disable)
hookPattern: '^use[A-Z]',
// Check function variables
checkFunctions: false,
// Ignore destructured variables
ignoreDestructuring: false,
// Ignore imported variables
ignoreImports: true,
}],
},
}, ];
// eslint.config.ts
export default [{
files: ['**/*.tsx'],
rules: {
'variable-naming/enforce-variable-naming-convention': ['error', {
caseType: 'camelCase',
componentCreators: ['lazy', 'memo', 'forwardRef', 'createContext'],
styledLibraries: ['styled'],
hookPattern: '^use[A-Z]',
ignoreImports: true,
}],
},
}, ];
// eslint.config.ts
export default [{
files: ['**/*.ts'],
rules: {
'variable-naming/enforce-variable-naming-convention': ['error', {
caseType: 'snake_case',
componentCreators: [],
styledLibraries: [],
hookPattern: null,
checkFunctions: true,
}],
},
}, ];
caseType (default: "camelCase")The naming convention to enforce:
"camelCase": myVariable"PascalCase": MyVariable"snake_case": my_variable"UPPER_SNAKE_CASE": MY_VARIABLE"kebab-case": my-variableallowedPatterns (default: [])Array of regex patterns for variable names to ignore:
{
"allowedPatterns": ["^_.*", "^CONSTANT_.*"]
}
excludeTypes (default: [])TypeScript types to exclude from checking:
{
"excludeTypes": ["Promise", "Observable"]
}
componentCreators: (default: ["lazy", "styled", "createElement", "memo", "forwardRef", "createContext"])Functions that create React components (set to [] to disable):
{
"componentCreators": ["lazy", "memo"]
}
styledLibraries (default: ["styled"])CSS-in-JS library names (set to [] to disable):
{
"styledLibraries": ["styled", "emotion"]
}
hookPattern (default: "^use[A-Z]")Regex pattern to match hook functions (set to null to disable):
{
"hookPattern": "^use[A-Z].*"
}
checkFunctions (default: false)Whether to check function variables:
{
"checkFunctions": true
}
ignoreDestructuring (default: false)Whether to ignore destructured variables:
{
"ignoreDestructuring": true
}
ignoreImports (default: false)Whether to ignore imported variables:
{
"ignoreImports": true
}
// ❌ Bad (with camelCase)
const MyVariable = 'value';
const my_variable = 123;
// ✅ Good (with camelCase)
const myVariable = 'value';
const anotherVar = 123;
MIT
FAQs
ESLint plugin to enforce consistent variable naming conventions with full configurability
We found that eslint-plugin-variable-naming demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.