eslint-plugin-lube 0.4.0 → 0.4.2
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/README.md +1 -0
- package/docs/pretty-sequence.md +6 -1
- package/package.json +1 -1
- package/private.d.ts +1 -0
- package/rules/pretty-sequence.js +13 -0
- package/test/pretty-sequence/case_by_option.js +15 -0
package/README.md
CHANGED
|
@@ -5,4 +5,5 @@
|
|
|
5
5
|
|---|---|---|---|
|
|
6
6
|
| pretty-imports | [docs](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/docs/pretty-imports.md) | [code](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/rules/pretty-imports.js) | [test](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/test/pretty-imports) |
|
|
7
7
|
| pretty-jsdoc-casting | [docs](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/docs/pretty-jsdoc-casting.md) | [code](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/rules/pretty-jsdoc-casting.js) | [test](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/test/pretty-jsdoc-casting) |
|
|
8
|
+
| pretty-sequence | [docs](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/docs/pretty-sequence.md) | [code](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/rules/pretty-sequence.js) | [test](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/test/pretty-sequence) |
|
|
8
9
|
| svelte-naming-convention | [docs](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/docs/svelte-naming-convention.md) | [code](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/rules/svelte-naming-convention.js) | [test](https://github.com/Artxe2/lube-series/blob/master/packages/eslint-plugin-lube/test/svelte-naming-convention) |
|
package/docs/pretty-sequence.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# pretty-
|
|
1
|
+
# pretty-sequence
|
|
2
2
|
Enforces arrays, objects, and functions to have a pretty format by enforcing proper indentation in sequences.
|
|
3
3
|
|
|
4
4
|
## options
|
|
@@ -12,6 +12,7 @@ schema: [
|
|
|
12
12
|
checkObject: { type: "boolean", default: true },
|
|
13
13
|
checkSequence: { type: "boolean", default: true },
|
|
14
14
|
funcCallSpacing: { type: "boolean", default: false },
|
|
15
|
+
ignoreTemplateLiteral: { type: "boolean", default: true },
|
|
15
16
|
indent: { type: "string", default: "\t" },
|
|
16
17
|
maxLength: { type: "number", default: 30 },
|
|
17
18
|
objectCurlySpacing: { type: "boolean", default: true }
|
|
@@ -32,6 +33,8 @@ If it is `true`, it checks the object statement.
|
|
|
32
33
|
If it is `true`, it checks the sequence statement.
|
|
33
34
|
### funcCallSpacing
|
|
34
35
|
If it is `true`, it inserts spaces inside function parenthesis.
|
|
36
|
+
### ignoreTemplateLiteral
|
|
37
|
+
If it is `true`, it ignores the template literal syntax.
|
|
35
38
|
### indent
|
|
36
39
|
This is the character to be used for indentation.
|
|
37
40
|
### maxLength
|
|
@@ -70,6 +73,8 @@ function func(
|
|
|
70
73
|
) {
|
|
71
74
|
|
|
72
75
|
}
|
|
76
|
+
var value = `${[a,b,c]}`
|
|
77
|
+
|
|
73
78
|
func(
|
|
74
79
|
aaaaaaaaaa_bbbbbbbbbb_cccccccccc
|
|
75
80
|
)
|
package/package.json
CHANGED
package/private.d.ts
CHANGED
package/rules/pretty-sequence.js
CHANGED
|
@@ -37,6 +37,7 @@ module.exports = {
|
|
|
37
37
|
checkObject: { type: "boolean", default: true },
|
|
38
38
|
checkSequence: { type: "boolean", default: true },
|
|
39
39
|
funcCallSpacing: { type: "boolean", default: false },
|
|
40
|
+
ignoreTemplateLiteral: { type: "boolean", default: true },
|
|
40
41
|
indent: { type: "string", default: "\t" },
|
|
41
42
|
maxLength: { type: "number", default: 30 },
|
|
42
43
|
objectCurlySpacing: { type: "boolean", default: true }
|
|
@@ -55,6 +56,7 @@ module.exports = {
|
|
|
55
56
|
const check_object = option?.checkObject ?? true
|
|
56
57
|
const check_sequence = option?.checkSequence ?? true
|
|
57
58
|
const func_call_spacing = option?.funcCallSpacing ?? false
|
|
59
|
+
const ignore_template_literal = option?.ignoreTemplateLiteral ?? true
|
|
58
60
|
const indent = option?.indent ?? "\t"
|
|
59
61
|
const max_length = option?.maxLength ?? 30
|
|
60
62
|
const object_curly_spacing = option?.objectCurlySpacing ?? true
|
|
@@ -70,6 +72,8 @@ module.exports = {
|
|
|
70
72
|
let [ start, end ] = comment.range
|
|
71
73
|
while (start < end) comments[start++] = comment
|
|
72
74
|
}
|
|
75
|
+
/** @type {true[]} */
|
|
76
|
+
const ignored_indexes = []
|
|
73
77
|
/** @type {import("../private").AstNode[] & import("estree").Expression[]} */
|
|
74
78
|
const nodes = []
|
|
75
79
|
|
|
@@ -144,6 +148,10 @@ module.exports = {
|
|
|
144
148
|
* @returns {void}
|
|
145
149
|
*/
|
|
146
150
|
function push_to_reverse(node) {
|
|
151
|
+
if (
|
|
152
|
+
ignore_template_literal
|
|
153
|
+
&& ignored_indexes[node.range[0]]
|
|
154
|
+
) return
|
|
147
155
|
nodes.push(node)
|
|
148
156
|
}
|
|
149
157
|
/**
|
|
@@ -411,6 +419,11 @@ module.exports = {
|
|
|
411
419
|
},
|
|
412
420
|
SequenceExpression: node => {
|
|
413
421
|
if (check_sequence) push_to_reverse(node)
|
|
422
|
+
},
|
|
423
|
+
TemplateLiteral: ({ range: [ start, end ] }) => {
|
|
424
|
+
if (ignore_template_literal) {
|
|
425
|
+
while (start < end) ignored_indexes[start++] = true
|
|
426
|
+
}
|
|
414
427
|
}
|
|
415
428
|
})/**/
|
|
416
429
|
}
|
|
@@ -108,4 +108,19 @@ exports.module = (valid, invalid) => {
|
|
|
108
108
|
parserOptions: { ecmaVersion: "latest" }
|
|
109
109
|
}
|
|
110
110
|
)
|
|
111
|
+
invalid.push(
|
|
112
|
+
{
|
|
113
|
+
code: `
|
|
114
|
+
var value = \`\${[a,b,c]}\`
|
|
115
|
+
`,
|
|
116
|
+
errors: [ {} ],
|
|
117
|
+
options: [
|
|
118
|
+
{ ignoreTemplateLiteral: false }
|
|
119
|
+
],
|
|
120
|
+
output: `
|
|
121
|
+
var value = \`\${[ a, b, c ]}\`
|
|
122
|
+
`,
|
|
123
|
+
parserOptions: { ecmaVersion: "latest" }
|
|
124
|
+
}
|
|
125
|
+
)
|
|
111
126
|
}
|