Linux command
eslint 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Lint JavaScript files
eslint [file.js]
Lint directory recursively
eslint [src/]
Fix auto-fixable
eslint --fix [file.js]
Specify config file
eslint -c [.eslintrc.json] [file.js]
Output in specific
eslint -f [json] [file.js]
Initialize configuration
eslint --init
Lint with extensions
eslint --ext [.js,.jsx,.ts,.tsx] [src/]
说明
ESLint is the standard linting tool for JavaScript and TypeScript. It statically analyzes code to find problems, enforce coding standards, and catch bugs before runtime. Rules are highly configurable through .eslintrc files. Plugins extend functionality for React, Vue, TypeScript, and other frameworks. The --fix flag automatically corrects many issues. ESLint integrates with editors and CI systems, making it central to JavaScript development workflows.
参数
- --fix
- Automatically fix problems.
- -c, --config _FILE_
- Configuration file.
- -f, --format _FORMAT_
- Output format.
- --ext _EXTENSIONS_
- File extensions to check.
- --init
- Create configuration file.
- --cache
- Cache results for faster runs.
- --quiet
- Report errors only.
- --help
- Display help information.
FAQ
What is the eslint command used for?
ESLint is the standard linting tool for JavaScript and TypeScript. It statically analyzes code to find problems, enforce coding standards, and catch bugs before runtime. Rules are highly configurable through .eslintrc files. Plugins extend functionality for React, Vue, TypeScript, and other frameworks. The --fix flag automatically corrects many issues. ESLint integrates with editors and CI systems, making it central to JavaScript development workflows.
How do I run a basic eslint example?
Run `eslint [file.js]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --fix do in eslint?
Automatically fix problems.