flatlint 1.4.0 → 1.4.1

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,8 @@
1
+ 2024.12.29, v1.4.1
2
+
3
+ feature:
4
+ - 1efda41 flatlint: add-missing-quote: semicolon
5
+
1
6
  2024.12.29, v1.4.0
2
7
 
3
8
  feature:
@@ -5,7 +5,7 @@ import {
5
5
  isPunctuator,
6
6
  isQuote,
7
7
  isStringLiteral,
8
- } from './types.js';
8
+ } from '../types/types.js';
9
9
 
10
10
  export const compare = (source, template) => {
11
11
  const templateTokens = prepare(template);
@@ -1,6 +1,6 @@
1
1
  import {compare} from '../compare/compare.js';
2
2
  import {traverse} from '../traverser/traverser.js';
3
- import {is} from '../compare/types.js';
3
+ import {is} from '../types/types.js';
4
4
  import {prepare} from '../tokenizer/index.js';
5
5
 
6
6
  const {entries} = Object;
@@ -2,7 +2,9 @@ import tokenize from 'js-tokens';
2
2
  import {
3
3
  isNewLine,
4
4
  isStringLiteral,
5
- } from '../compare/types.js';
5
+ Punctuator,
6
+ StringLiteral,
7
+ } from '#types';
6
8
 
7
9
  const isString = (a) => typeof a === 'string';
8
10
 
@@ -15,26 +17,19 @@ const closeQuotes = (tokens) => {
15
17
  if (isStringLiteral(token)) {
16
18
  const {closed, value} = token;
17
19
 
18
- const quote = {
19
- type: 'Punctuator',
20
- value: value.at(0),
21
- };
22
-
20
+ const quote = Punctuator(value.at(0));
23
21
  const newTokens = [];
24
22
 
25
23
  if (closed) {
26
- const literal = {
27
- value: value.slice(1, -1),
28
- type: 'StringLiteral',
29
- };
30
-
24
+ const literal = StringLiteral(value.slice(1, -1));
31
25
  newTokens.push(quote, literal, quote);
32
- } else {
33
- const literal = {
34
- value: value.slice(1),
35
- type: 'StringLiteral',
36
- };
26
+ } else if (value.endsWith(';')) {
27
+ const literal = StringLiteral(value.slice(1, -1));
28
+ const semicolon = Punctuator(';');
37
29
 
30
+ newTokens.push(quote, literal, semicolon);
31
+ } else {
32
+ const literal = StringLiteral(value.slice(1));
38
33
  newTokens.push(quote, literal);
39
34
  }
40
35
 
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isIdentifier,
3
3
  isStringLiteral,
4
- } from '../compare/types.js';
4
+ } from '../types/types.js';
5
5
 
6
6
  const maybeCall = (fn, a) => fn?.(a);
7
7
 
@@ -8,6 +8,16 @@ export const isNewLine = ({type}) => type === 'LineTerminatorSequence';
8
8
  export const notWhiteSpace = (a) => !isWhiteSpace(a);
9
9
  export const isPunctuator = ({type}) => type === 'Punctuator';
10
10
 
11
+ export const StringLiteral = (value) => ({
12
+ type: 'StringLiteral',
13
+ value,
14
+ });
15
+
16
+ export const Punctuator = (value) => ({
17
+ type: 'Punctuator',
18
+ value,
19
+ });
20
+
11
21
  export const is = (str, array = ALL) => {
12
22
  for (const item of array) {
13
23
  if (check(str, item))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",
@@ -11,6 +11,9 @@
11
11
  "#test": {
12
12
  "default": "./lib/test/test.js"
13
13
  },
14
+ "#types": {
15
+ "default": "./lib/types/types.js"
16
+ },
14
17
  "#flatlint": {
15
18
  "default": "./lib/flatlint.js"
16
19
  }