flatlint 1.18.0 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -121,6 +121,17 @@ const a = {
|
|
|
121
121
|
|
|
122
122
|
</details>
|
|
123
123
|
|
|
124
|
+
<details><summary>Remove useless coma</summary>
|
|
125
|
+
|
|
126
|
+
```diff
|
|
127
|
+
const a = class {
|
|
128
|
+
- b() {},
|
|
129
|
+
+ b() {}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
</details>
|
|
134
|
+
|
|
124
135
|
## Template literals
|
|
125
136
|
|
|
126
137
|
**FlatLint** uses language similar to 🐊[**PutoutScript**](https://github.com/coderaiser/putout/blob/master/docs/putout-script.md#-putoutscript).
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
return 'Use semicolon instead of trailing comma';
|
|
3
|
-
}
|
|
1
|
+
import {isIdentifier} from '#types';
|
|
4
2
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export const report = () => 'Use semicolon instead of trailing comma';
|
|
4
|
+
export const match = () => ({
|
|
5
|
+
'__a: __expr;': (vars, path) => {
|
|
6
|
+
for (const token of path.getPrev()) {
|
|
7
|
+
if (isIdentifier(token, 'interface'))
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return true;
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
export const replace = () => ({
|
|
15
|
+
'const __a = __b,': 'const __a = __b;',
|
|
16
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {isIdentifier} from '#types';
|
|
2
|
+
|
|
3
|
+
export const report = () => 'Remove useless coma';
|
|
4
|
+
|
|
5
|
+
export const match = () => ({
|
|
6
|
+
'__a() {},': (vars, path) => {
|
|
7
|
+
for (const token of path.getPrev()) {
|
|
8
|
+
if (isIdentifier(token, 'class'))
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return false;
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const replace = () => ({
|
|
17
|
+
'__a() {},': '__a() {}',
|
|
18
|
+
});
|
package/lib/types/types.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
const isString = (a) => typeof a === 'string';
|
|
2
2
|
|
|
3
3
|
export const isWhiteSpace = ({type}) => type === 'WhiteSpace';
|
|
4
|
-
export const isIdentifier = (
|
|
4
|
+
export const isIdentifier = (token, value = token.value) => {
|
|
5
|
+
const {type} = token;
|
|
6
|
+
const is = type === 'IdentifierName';
|
|
7
|
+
|
|
8
|
+
if (!is)
|
|
9
|
+
return false;
|
|
10
|
+
|
|
11
|
+
return value === token.value;
|
|
12
|
+
};
|
|
13
|
+
|
|
5
14
|
export const isStringLiteral = ({type}) => type === 'StringLiteral';
|
|
6
15
|
export const isNumericLiteral = ({type}) => type === 'NumericLiteral';
|
|
7
16
|
export const isNewLine = ({type}) => type === 'LineTerminatorSequence';
|