@labeg/code-style
v6.10.19
Published
Code styles rules for difference linters, for create best code quality
Readme
CodeStyle
Comprehensive ESLint configuration for TypeScript and React projects with strict code quality rules.
Features
- ✅ ESLint 9+ with flat config format
- ✅ TypeScript support with strict rules
- ✅ React 19+ and React Hooks best practices
- ✅ Accessibility checks (jsx-a11y)
- ✅ Code style enforcement (@stylistic)
- ✅ Modern JavaScript standards
Included Plugins
This configuration includes and configures the following ESLint plugins:
- @eslint/js - Core ESLint JavaScript rules
- typescript-eslint - TypeScript-specific linting rules
- @stylistic/eslint-plugin - Code formatting and style rules
- eslint-plugin-react - React-specific linting rules
- eslint-plugin-react-hooks - Rules for React Hooks
- eslint-plugin-jsx-a11y - Accessibility rules for JSX (commented out, see config)
Installation
Install the package as a dev dependency:
npm install -D @labeg/code-styleUsage
ESLint 9+ (Flat Config)
Create or update your eslint.config.js:
import codeStyle from "@labeg/code-style";
export default [
...codeStyle,
{
// Your custom overrides
rules: {
// Override specific rules here
}
}
];Next.js Projects
import nextVitals from "eslint-config-next/core-web-vitals";
import codeStyle from "@labeg/code-style";
export default [
...nextVitals,
...codeStyle,
{
rules: {
// Next.js specific overrides
"react/react-in-jsx-scope": "off"
}
}
];TypeScript Projects
The configuration automatically works with TypeScript files (.ts, .tsx). Make sure you have typescript installed:
npm install -D typescriptCode Style Philosophy
Always End Lines with Operators or Semicolons
Lines should always end with an operator or semicolon to make it clear whether the statement continues. This saves reading time and prevents execution errors.
// Bad - unclear if statement continues
let sample = sample.sample.sample
+ sample.sample.sample;
// Good - operator at end shows continuation
let sample = sample.sample.sample +
sample.sample.sample;Always Use Braces for If Statements
Even for single-line statements, always use braces. This prevents bugs during refactoring and improves code clarity.
// Bad
if (n > 10) alert("Bad");
// Good
if (n > 10) {
alert("Good");
}Use Double Quotes and Template Literals
Use double quotes for consistency with other languages, and template literals for string interpolation.
const message = "rolls";
const count = 5;
// Bad
const data = 'Sending "grandma" ' + count * 5 + ' ' + message + '.';
// Good
const data = `Sending "grandma" ${count * 5} ${message}.`;Line Length: 120 Characters, Indent: 4 Spaces
Optimal line length is 120 characters for readability across different monitors. Use 4-space indentation for clear nesting levels.
Security
For security concerns, please see our Security Policy.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT © Eugene Labutin
