flatlint 1.115.0 → 2.0.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
@@ -1,3 +1,14 @@
1
+ 2025.02.17, v2.0.0
2
+
3
+ feature:
4
+ - a650691 flatlint: convert-colon-to-semicolon: add
5
+
6
+ 2025.02.15, v1.116.0
7
+
8
+ feature:
9
+ - 80bf900 convert-semicolon-to-comma: class (#1)
10
+ - e58018d flatlint: parser: add support of multiline comments
11
+
1
12
  2025.02.15, v1.115.0
2
13
 
3
14
  feature:
package/README.md CHANGED
@@ -1,4 +1,13 @@
1
- # FlatLint
1
+ # FlatLint[![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]
2
+
3
+ [NPMURL]: https://npmjs.org/package/flatlint "npm"
4
+ [NPMIMGURL]: https://img.shields.io/npm/v/flatlint.svg?style=flat
5
+ [BuildStatusURL]: https://github.com/coderaiser/flatlint/actions?query=workflow%3A%22Node+CI%22 "Build Status"
6
+ [BuildStatusIMGURL]: https://github.com/coderaiser/flatlint/workflows/Node%20CI/badge.svg
7
+ [LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
8
+ [LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
9
+ [CoverageURL]: https://coveralls.io/github/coderaiser/flatlint?branch=master
10
+ [CoverageIMGURL]: https://coveralls.io/repos/coderaiser/flatlint/badge.svg?branch=master&service=github
2
11
 
3
12
  Token-based JavaScript linter that fixes Syntax Errors
4
13
 
@@ -10,7 +19,7 @@ npm i flatlint
10
19
 
11
20
  ## Available fixes
12
21
 
13
- <details><summary>Assignment without parentheses after <code>&&</code></summary>
22
+ <details><summary>assignment without parentheses after <code>&&</code></summary>
14
23
 
15
24
  ```diff
16
25
  -a && b = c;
@@ -40,6 +49,15 @@ module.exports = 2;
40
49
 
41
50
  </details>
42
51
 
52
+ <details><summary>convert colon to semicolon</summary>
53
+
54
+ ```diff
55
+ -console.log(a, b):
56
+ +console.log(a, b);
57
+ ```
58
+
59
+ </details>
60
+
43
61
  <details><summary>convert <code>from</code> to <code>require</code></summary>
44
62
 
45
63
  ```diff
@@ -356,3 +374,4 @@ const [code] = lint(`a && b = c`, {
356
374
  ## License
357
375
 
358
376
  MIT
377
+
@@ -1,5 +1,6 @@
1
1
  import tokenize from 'js-tokens';
2
2
  import {
3
+ isMultilineComment,
3
4
  isNewLine,
4
5
  isStringLiteral,
5
6
  } from '#types';
@@ -46,6 +47,9 @@ function getTokensWithLocation(tokens) {
46
47
  if (isNewLine(token))
47
48
  ++line;
48
49
 
50
+ if (isMultilineComment(token))
51
+ line += token.value.split('\n').length - 1;
52
+
49
53
  result.push({
50
54
  ...token,
51
55
  line,
@@ -60,3 +64,4 @@ function getTokensWithLocation(tokens) {
60
64
 
61
65
  return result;
62
66
  }
67
+
@@ -0,0 +1,5 @@
1
+ export const report = () => `Use ';' instead of ':'`;
2
+ export const replace = () => ({
3
+ '):': ');',
4
+ });
5
+
@@ -28,7 +28,7 @@ export const match = () => ({
28
28
  },
29
29
  '__a: __expr;': (vars, path) => {
30
30
  for (const token of path.getAllPrev()) {
31
- if (isOneOfKeywords(token, ['readonly', 'static', 'implements']))
31
+ if (isOneOfKeywords(token, ['class', 'readonly', 'static', 'implements']))
32
32
  return false;
33
33
  }
34
34
 
@@ -29,6 +29,7 @@ export const isIdentifier = (token, newToken) => {
29
29
  export const isStringLiteral = ({type}) => type === 'StringLiteral';
30
30
  export const isNumericLiteral = ({type}) => type === 'NumericLiteral';
31
31
  export const isNewLine = ({type}) => type === 'LineTerminatorSequence';
32
+ export const isMultilineComment = ({type}) => type === 'MultiLineComment';
32
33
 
33
34
  export const isKeyword = (token, name) => {
34
35
  if (!token)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.115.0",
3
+ "version": "2.0.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",