$ npm install samadhi
Samadhi (Sanskrit, समाधि) is a state of meditative consciousness.
🧘🏽Samadhi linter finds and fixes syntax errors.
npm i samadhi --save
-function parse(source) => {
+function parse(source) {
return source;
}
-const a = 'hello;
+const a = 'hello';
const b = 'world';
-x('hello);
+x('hello');
const m = {
- z: x('hello
+ z: x('hello'),
}
-if a > 5 {
+if (a > 5) {
alert();
}
-const {code, places} await samadhi(source);
+const {code, places} = await samadhi(source);
-import hello from hello;
+import hello from 'hello';
function x() {
- return 'hello',
+ return 'hello';
}
-const a = 5,
+const a = 5;
const a = {
- b: 'hello',,
+ b: 'hello',
}
const a = {
- b: 'hello';
+ b: 'hello',
}
const a = class {
- b() {},
+ b() {}
}
-const a = from 'a';
+const a = require('a');
Possible options:
interface Options {
isJSX: boolean;
isTS: boolean;
startLine: number;
}
Here is example:
import {lint} from 'samadhi';
const source = `
function x() => {
return 'hello';
}
`;
const [code, places] = await lint(source);
// places:
[{
rule: 'parser (quick-lint-js)',
message: `functions/methods should not have '=>'`,
position: {
line: 2,
column: 8,
},
}];
You can also fix
results:
const [code] = await lint(source, {
fix: true,
});
// returns
function x() {
return 'hello';
}
MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE