Linting
Linting
Checks for errors/style through static code analysis. ESLint, Pylint, Clippy.
Linting
Checks for errors/style through static code analysis. ESLint, Pylint, Clippy.
Linting is the process of statically analyzing source code, without executing it, to find potential errors, bugs, style violations, and suspicious code patterns. A tool called a linter performs this analysis and plays a key role in maintaining code quality and consistency.
Linters widely used in modern development include ESLint for JavaScript/TypeScript, Pylint/Ruff/flake8 for Python, Clippy for Rust, golangci-lint for Go, and clang-tidy for C/C++. Each language ecosystem has an established standard linter, which helps unify code style across teams.
Linting mainly checks three things. First, potential bugs such as syntax errors and type problems. Second, code style such as indentation, quote style, and semicolon usage. Third, code quality issues such as unused variables, overly complex functions, and unsafe code patterns.
It is common to integrate linting into the CI/CD pipeline so that it runs automatically at the Pull Request stage, and to block merging if there are lint errors. Integrating it with an IDE extension or a pre-commit hook lets you check locally before committing, which speeds up the development cycle.
// .eslintrc.js - ESLint μ€μ νμΌ
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 2022,
sourceType: 'module'
},
plugins: ['@typescript-eslint', 'import', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/typescript',
'prettier' // Prettierμ μΆ©λ κ·μΉ λΉνμ±ν
],
rules: {
// νμ
μμ μ±
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/strict-boolean-expressions': 'warn',
// μ½λ νμ§
'no-console': ['warn', { allow: ['warn', 'error'] }],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_'
}],
// import μ 리
'import/order': ['error', {
groups: ['builtin', 'external', 'internal'],
'newlines-between': 'always',
alphabetize: { order: 'asc' }
}]
},
ignorePatterns: ['dist/', 'node_modules/', '*.config.js']
};
# pyproject.toml - Ruff/Pylint μ€μ (Python)
[tool.ruff]
target-version = "py311"
line-length = 100
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"S", # flake8-bandit (보μ)
]
ignore = ["E501"] # line too long (Formatterκ° μ²λ¦¬)
[tool.ruff.per-file-ignores]
"tests/*" = ["S101"] # ν
μ€νΈμμ assert νμ©
[tool.pylint.messages_control]
disable = ["missing-docstring", "too-few-public-methods"]
max-line-length = 100
good-names = ["i", "j", "k", "x", "y", "id"]
# pre-commit μ€μ (.pre-commit-config.yaml)
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
Lead: "If there are ESLint rules our team often ignores, let's discuss and adjust them. Overusing eslint-disable for no good reason isn't good."
Junior: "The no-console rule makes debugging inconvenient. How about lowering it to the warn level?"
Senior: "Sounds good. Also, since merging is blocked in CI when there are lint errors, it would be good to get into the habit of running it locally once before committing."
Interviewer: "What tools have you used to maintain code quality?"
Candidate: "I used ESLint and Prettier together. I set up Husky and lint-staged so that only changed files are linted on commit, and I also ran a full lint on every PR in GitHub Actions. I used eslint-config-airbnb as the base for the lint rules and customized it to fit the team."
Take a mock interview on this topic β WIA SOOM AI Interview Β· Start for free
Reviewer: "This function has `// eslint-disable-next-line @typescript-eslint/no-explicit-any` attached. Please leave a comment explaining why you needed to use any."
Author: "There were no types for the third-party library, so I temporarily used any. I'll create an issue and either find an @types package or add the declaration myself."