Replies: 4 comments 2 replies
-
cc / @aladdin-add |
Beta Was this translation helpful? Give feedback.
-
I would suggest the similar API as eslint (if possible) :) All of this depends on what's the goal of the linter.
the public API can be something like const config = {
globals: {},
rules: {},
};
const options = {
fix: true/false,
filename: string,
//...
};
kataw.lint(code, config, options); just my 2 cents! :) |
Beta Was this translation helpful? Give feedback.
-
@aladdin-add See #89 |
Beta Was this translation helpful? Give feedback.
-
Kataw are undergoing a mayor refactoring (not released yet) so the linter config and options has now changed. The Each of this The This is Kataw's config file: {
"files": ["**/*.js"],
"module": false,
"typecheck": false,
"linter": {
"enable": true,
"extends": [
"kataw:recommended"
],
"rules": {},
"rulesDirectory": []
},
"minify": {
"enable": false,
"options": {}
},
"prettify": {
"enable": true,
"options": {}
}
} |
Beta Was this translation helpful? Give feedback.
-
The basic idea for the linter is to add an
autoFix
option to the parser and let the parser fix "fixable" errors during parsing, and eventually report an diagnostic . Some "errors" are an easy fix such as double quote vs single quote - it only require to swap the bitwise masks before the printer print the CST node.Implementing a linter this way eliminates the need for an external walker, and maintain perf.
There are things to consider before implementing this
How should the API look like? It can't be part of the main parser option because it will be too many options.
How could we implement additional rules?
Beta Was this translation helpful? Give feedback.
All reactions