@mahdi.golzar/autolinter
v1.0.0
Published
AutoLinter is a simple tool for automatically linting and fixing your code. It allows you to define custom linting rules that can automatically detect and correct common code issues.
Downloads
12
Readme
AutoLinter
AutoLinter is a simple tool for automatically linting and fixing your code. It allows you to define custom linting rules that can automatically detect and correct common code issues.
Features
- Custom Linting Rules: Define and apply your own linting rules.
- Automatic Code Correction: Automatically fixes code based on the defined rules.
- File Linting: Lint and fix entire files with ease.
Installation
No installation is required for this code as it is self-contained and can be added directly to your project.
Usage
- Create an AutoLinter Instance
const linter = new AutoLinter();
- Define Linting Rules Add custom linting rules using the addRule method:
linter.addRule({
pattern: /var\s+/g,
replacement: 'let ',
});
linter.addRule({
pattern: /==/g,
replacement: '===',
});
- Lint and Fix Code Use the lint method to lint and fix a string of code:
const lintedCode = linter.lint(sampleCode);
console.log("Linted Code:\n", lintedCode);
- Lint and Fix Files Lint and fix an entire file using the lintFile method:
linter.lintFile('./path/to/your/file.js');