eslint-plugin-lube 0.3.4 → 0.4.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/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Eslint plugin lube
2
+ ## Full fixable rules for auto-formatting with ESLint only without Prettier
2
3
 
3
4
  | Rule | Docs | Code | Test |
4
5
  |---|---|---|---|
5
- | 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) |
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) |
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
+ | 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
+ | 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) |
@@ -3,31 +3,18 @@ Enforces proper indentation for import and export statements.
3
3
 
4
4
  ## options
5
5
  ```js
6
- schema: [{
7
- properties: {
8
- checkExports: {
9
- type: "boolean",
10
- default: true
6
+ schema: [
7
+ {
8
+ properties: {
9
+ checkExports: { type: "boolean", default: true },
10
+ checkImports: { type: "boolean", default: true },
11
+ indent: { type: "string", default: "\t" },
12
+ maxLength: { type: "number", default: 30 },
13
+ semicolon: { type: "boolean", default: false }
11
14
  },
12
- checkImports: {
13
- type: "boolean",
14
- default: true
15
- },
16
- indent: {
17
- type: "string",
18
- default: "\t"
19
- },
20
- maxLength: {
21
- type: "number",
22
- default: 30
23
- },
24
- semicolon: {
25
- type: "boolean",
26
- default: false
27
- }
28
- },
29
- type: "object"
30
- }]
15
+ type: "object"
16
+ }
17
+ ]
31
18
  ```
32
19
  ### checkExports
33
20
  If it is `true`, it checks the export statement.
@@ -1,5 +1,5 @@
1
- # pretty-imports
2
- Enforces proper indentation for import and export statements.
1
+ # pretty-jsdoc-casting
2
+ Enforces additional empty comment when type casting in JSDoc.
3
3
 
4
4
  ## options
5
5
  ```js
@@ -0,0 +1,113 @@
1
+ # pretty-imports
2
+ Enforces arrays, objects, and functions to have a pretty format by enforcing proper indentation in sequences.
3
+
4
+ ## options
5
+ ```js
6
+ schema: [
7
+ {
8
+ properties: {
9
+ arrayBracketSpacing: { type: "boolean", default: true },
10
+ checkCall: { type: "boolean", default: true },
11
+ checkArray: { type: "boolean", default: true },
12
+ checkObject: { type: "boolean", default: true },
13
+ checkSequence: { type: "boolean", default: true },
14
+ funcCallSpacing: { type: "boolean", default: false },
15
+ indent: { type: "string", default: "\t" },
16
+ maxLength: { type: "number", default: 30 },
17
+ objectCurlySpacing: { type: "boolean", default: true }
18
+ },
19
+ type: "object"
20
+ }
21
+ ]
22
+ ```
23
+ ### arrayBracketSpacing
24
+ If it is `true`, it inserts spaces inside array brackets.
25
+ ### checkArray
26
+ If it is `true`, it checks the array statement.
27
+ ### checkCall
28
+ If it is `true`, it checks the function statement.
29
+ ### checkObject
30
+ If it is `true`, it checks the object statement.
31
+ ### checkSequence
32
+ If it is `true`, it checks the sequence statement.
33
+ ### funcCallSpacing
34
+ If it is `true`, it inserts spaces inside function parenthesis.
35
+ ### indent
36
+ This is the character to be used for indentation.
37
+ ### maxLength
38
+ If the sum of the characters in the Sequences is greater than the set value, apply line breaks.
39
+ ```js
40
+ // If maxLength is less than or equal to 20, an error occurs.
41
+ var value = { fff, ggg, hhh, iii, jjj, kkk, lll }
42
+ ```
43
+ ### objectCurlySpacing
44
+ If it is `true`, it inserts spaces inside object braces.
45
+
46
+ ## Valid
47
+ ```js
48
+ var value = [ a, b, c ]
49
+ var value = [
50
+ aaaaaaaaaa,
51
+ bbbbbbbbbb,
52
+ cccccccccc,
53
+ dddddddddd
54
+ ]
55
+ var value = { a, b, c, d, e }
56
+ var value = {
57
+ aaaaaaaaaa,
58
+ bbbbbbbbbb,
59
+ cccccccccc,
60
+ dddddddddd
61
+ }
62
+ function func(a, b, c) {
63
+
64
+ }
65
+ function func(
66
+ aaaaaaaaaa,
67
+ bbbbbbbbbb,
68
+ cccccccccc,
69
+ dddddddddd
70
+ ) {
71
+
72
+ }
73
+ func(
74
+ aaaaaaaaaa_bbbbbbbbbb_cccccccccc
75
+ )
76
+ .a(
77
+ aaaaaaaaaa_bbbbbbbbbb_cccccccccc
78
+ )
79
+ .b(
80
+ aaaaaaaaaa_bbbbbbbbbb_cccccccccc
81
+ )
82
+ .c(
83
+ aaaaaaaaaa_bbbbbbbbbb_cccccccccc
84
+ )
85
+
86
+ var value = {
87
+ a: [ a, b, c ],
88
+ b: true,
89
+ c: {
90
+ aaaaaaaaaa: a,
91
+ bbbbbbbbbb: b,
92
+ c: [
93
+ aaaaaaaaaa,
94
+ bbbbbbbbbbb,
95
+ ccccccccccc
96
+ ],
97
+ d: {
98
+ aaaaaaaaaa,
99
+ bbbbbbbbbbb,
100
+ ccccccccccc
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ ## Invalid
107
+ ```js
108
+ var value = [a,b,c]
109
+ var value = { aaaaaaaaaa, bbbbbbbbbb, cccccccccc, dddddddddd }
110
+ new Obj(
111
+
112
+ )
113
+ ```
@@ -4,15 +4,14 @@ Enforces snake_case with some symbols for variable declaration.
4
4
 
5
5
  ## options
6
6
  ```js
7
- schema: [{
8
- properties: {
9
- fixSameNames: {
10
- type: "boolean",
11
- default: true
7
+ schema: [
8
+ {
9
+ properties: {
10
+ fixSameNames: { type: "boolean", default: true }
12
11
  },
13
- },
14
- type: "object"
15
- }]
12
+ type: "object"
13
+ }
14
+ ]
16
15
  ```
17
16
  ### fixSameNames
18
17
  If set to `true`, an error will be returned if the variable name is the same, even in the case of function calls that are the target of `defer`.
package/index.js CHANGED
@@ -6,66 +6,52 @@
6
6
  module.exports = {
7
7
  configs: {
8
8
  recommended: {
9
- extends: ["eslint:recommended"],
10
- plugins: ["lube"],
9
+ extends: [ "eslint:recommended" ],
10
+ plugins: [ "lube" ],
11
11
  rules: {
12
- "array-bracket-newline": [
13
- "error", {
14
- "multiline": true
15
- }
16
- ],
17
- "array-element-newline": ["error", "consistent"],
18
- "arrow-parens": ["error", "as-needed"],
12
+ "array-bracket-newline": [ "error", "consistent" ],
13
+ "array-element-newline": [ "error", "consistent" ],
14
+ "arrow-parens": [ "error", "as-needed" ],
19
15
  "arrow-spacing": [
20
- "error", {
21
- "before": true,
22
- "after": true
23
- }
16
+ "error",
17
+ { "before": true, "after": true }
24
18
  ],
25
- "block-spacing": ["error", "always"],
26
- "brace-style": ["error", "1tbs"],
27
- "comma-dangle": ["error", "never"],
19
+ "block-spacing": [ "error", "always" ],
20
+ "brace-style": [ "error", "1tbs" ],
21
+ "comma-dangle": [ "error", "never" ],
28
22
  "comma-spacing": [
29
- "error", {
30
- "before": false,
31
- "after": true
32
- }
23
+ "error",
24
+ { "before": false, "after": true }
33
25
  ],
34
- "comma-style": ["error", "last"],
35
- "computed-property-spacing": ["error", "never"],
36
- "dot-location": ["error", "property"],
37
- "eol-last": ["error", "never"],
38
- "func-call-spacing": ["error", "never"],
39
- "function-call-argument-newline": ["error", "consistent"],
40
- "generator-star-spacing": ["error", "after"],
41
- "indent": ["error", "tab"],
42
- "jsx-quotes": ["error", "prefer-double"],
26
+ "comma-style": [ "error", "last" ],
27
+ "computed-property-spacing": [ "error", "never" ],
28
+ "dot-location": [ "error", "property" ],
29
+ "eol-last": [ "error", "never" ],
30
+ "func-call-spacing": [ "error", "never" ],
31
+ "function-call-argument-newline": [ "error", "consistent" ],
32
+ "generator-star-spacing": [ "error", "after" ],
33
+ "indent": [ "error", "tab" ],
34
+ "jsx-quotes": [ "error", "prefer-double" ],
43
35
  "key-spacing": [
44
- "error", {
36
+ "error",
37
+ {
45
38
  "afterColon": true,
46
39
  "beforeColon": false
47
40
  }
48
41
  ],
49
42
  "keyword-spacing": [
50
- "error", {
51
- "after": true,
52
- "before": true
53
- }
54
- ],
55
- "max-len": ["warn", 120],
56
- "max-nested-callbacks": ["error", 3],
57
- "max-statements-per-line": [
58
- "error", {
59
- "max": 1
60
- }
43
+ "error",
44
+ { "after": true, "before": true }
61
45
  ],
62
- "multiline-ternary": ["error", "always-multiline"],
46
+ "max-len": [ "warn", 120 ],
47
+ "max-statements-per-line": [ "error", { "max": 1 } ],
48
+ "multiline-ternary": [ "error", "always-multiline" ],
63
49
  "newline-per-chained-call": [
64
- "error", {
65
- "ignoreChainWithDepth": 2
66
- }
50
+ "error",
51
+ { "ignoreChainWithDepth": 2 }
67
52
  ],
68
- "no-await-in-loop": "error",
53
+ "no-await-in-loop": "warn",
54
+ "no-case-declarations": "off",
69
55
  "no-console": "warn",
70
56
  "no-duplicate-imports": "error",
71
57
  "no-lonely-if": "error",
@@ -75,65 +61,55 @@ module.exports = {
75
61
  "no-shadow": "error",
76
62
  "no-shadow-restricted-names": "error",
77
63
  "no-trailing-spaces": [
78
- "error", {
64
+ "error",
65
+ {
79
66
  "ignoreComments": false,
80
67
  "skipBlankLines": false
81
68
  }
82
69
  ],
83
- "object-curly-newline": [
84
- "error", {
85
- "consistent": true
86
- }
87
- ],
88
- "object-curly-spacing": ["error", "always"],
89
- "operator-linebreak": ["error", "before"],
70
+ "object-curly-newline": [ "error", { "consistent": true } ],
71
+ "object-curly-spacing": [ "error", "always" ],
72
+ "operator-linebreak": [ "error", "before" ],
90
73
  "prefer-const": [
91
- "warn", {
74
+ "warn",
75
+ {
92
76
  "destructuring": "all",
93
77
  "ignoreReadBeforeAssign": false
94
78
  }
95
79
  ],
96
- "quotes": ["error", "double"],
97
- "rest-spread-spacing": ["error", "never"],
98
- "semi": ["error", "never"],
80
+ "quotes": [ "error", "double" ],
81
+ "rest-spread-spacing": [ "error", "never" ],
82
+ "semi": [ "error", "never" ],
99
83
  "semi-spacing": [
100
- "error", {
101
- "after": true,
102
- "before": false
103
- }
84
+ "error",
85
+ { "after": true, "before": false }
104
86
  ],
105
- "semi-style": ["error", "first"],
106
- "space-before-blocks": ["error", "always"],
87
+ "semi-style": [ "error", "first" ],
88
+ "space-before-blocks": [ "error", "always" ],
107
89
  "space-before-function-paren": [
108
- "error", {
90
+ "error",
91
+ {
109
92
  "anonymous": "never",
110
93
  "asyncArrow": "always",
111
94
  "named": "never"
112
95
  }
113
96
  ],
114
- "space-in-parens": ["error", "never"],
115
- "space-infix-ops": [
116
- "error", {
117
- "int32Hint": true
118
- }
119
- ],
97
+ "space-in-parens": [ "error", "never" ],
98
+ "space-infix-ops": [ "error", { "int32Hint": true } ],
120
99
  "space-unary-ops": [
121
- "error", {
122
- "words": true,
123
- "nonwords": false
124
- }
100
+ "error",
101
+ { "words": true, "nonwords": false }
125
102
  ],
126
103
  "switch-colon-spacing": [
127
- "error", {
128
- "after": true,
129
- "before": false
130
- }
104
+ "error",
105
+ { "after": true, "before": false }
131
106
  ],
132
- "template-curly-spacing": ["error", "never"],
133
- "template-tag-spacing": ["error", "never"],
134
- "yield-star-spacing": ["error", "after"],
107
+ "template-curly-spacing": [ "error", "never" ],
108
+ "template-tag-spacing": [ "error", "never" ],
109
+ "yield-star-spacing": [ "error", "after" ],
135
110
  "lube/pretty-imports": "error",
136
111
  "lube/pretty-jsdoc-casting": "error",
112
+ "lube/pretty-sequence": "error",
137
113
  "lube/svelte-naming-convention": "error"
138
114
  }
139
115
  }
@@ -141,6 +117,9 @@ module.exports = {
141
117
  rules: {
142
118
  "pretty-imports": require("./rules/pretty-imports"),
143
119
  "pretty-jsdoc-casting": require("./rules/pretty-jsdoc-casting"),
144
- "svelte-naming-convention": require("./rules/svelte-naming-convention")
120
+ "pretty-sequence": require("./rules/pretty-sequence"),
121
+ "svelte-naming-convention": require(
122
+ "./rules/svelte-naming-convention"
123
+ )
145
124
  }
146
125
  }
package/package.json CHANGED
@@ -1,26 +1,34 @@
1
- {
2
- "author": "artxe2",
3
- "bugs": {
4
- "url": "https://github.com/Artxe2/lube-series/issues"
5
- },
6
- "description": "Eslint rules expand options",
7
- "devDependencies": {
8
- "@types/eslint": "^8.44.6",
9
- "@types/estree": "^1.0.3",
10
- "@typescript-eslint/parser": "^6.8.0",
11
- "eslint": "^8.52.0",
12
- "mocha": "^10.2.0"
13
- },
14
- "license": "MIT",
15
- "name": "eslint-plugin-lube",
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/Artxe2/lube-series",
19
- "directory": "packages/eslint-plugin-lube"
20
- },
21
- "scripts": {
22
- "test": "mocha"
23
- },
24
- "type": "commonjs",
25
- "version": "0.3.4"
1
+ {
2
+ "author": "artxe2",
3
+ "bugs": {
4
+ "url": "https://github.com/Artxe2/lube-series/issues"
5
+ },
6
+ "description": "Full fixable rules for auto-formatting with ESLint only without Prettier",
7
+ "devDependencies": {
8
+ "@types/eslint": "^8.44.6",
9
+ "@types/estree": "^1.0.3",
10
+ "@typescript-eslint/parser": "^6.9.0",
11
+ "eslint": "^8.52.0",
12
+ "mocha": "^10.2.0"
13
+ },
14
+ "keywords": [
15
+ "eslint-plugin",
16
+ "lube",
17
+ "eslint-plugin-lube",
18
+ "prettier",
19
+ "jsdoc"
20
+ ],
21
+ "license": "MIT",
22
+ "name": "eslint-plugin-lube",
23
+ "repository": {
24
+ "directory": "packages/eslint-plugin-lube",
25
+ "type": "git",
26
+ "url": "https://github.com/Artxe2/lube-series"
27
+ },
28
+ "scripts": {
29
+ "dts": "tsc",
30
+ "test": "mocha"
31
+ },
32
+ "type": "commonjs",
33
+ "version": "0.4.0"
26
34
  }
package/private.d.ts CHANGED
@@ -1,34 +1,30 @@
1
+ import * as eslint from "eslint"
1
2
  import * as estree from "estree"
2
3
 
3
- export type BaseAstNode = {
4
- parent: AstNode
5
- range: [number, number]
6
- }
7
-
8
4
  export type AstNode = BaseAstNode & (
9
- estree.ArrayExpression & {
5
+ {
10
6
  elements: AstNode[]
11
- }
12
- | estree.ArrayPattern & {
7
+ } & estree.ArrayExpression
8
+ | {
13
9
  elements: AstNode[]
14
- }
15
- | estree.ArrowFunctionExpression & {
10
+ } & estree.ArrayPattern
11
+ | {
16
12
  body: AstNode
17
13
  params: AstNode[]
18
- }
19
- | estree.AssignmentExpression & {
14
+ } & estree.ArrowFunctionExpression
15
+ | {
20
16
  left: AstNode
21
17
  right: AstNode
22
- }
18
+ } & estree.AssignmentExpression
23
19
  | estree.AssignmentPattern
24
20
  | estree.AwaitExpression
25
21
  | estree.BinaryExpression
26
22
  | estree.BlockStatement
27
23
  | estree.BreakStatement
28
- | estree.CallExpression & {
24
+ | {
29
25
  callee: AstNode
30
26
  arguments: AstNode[]
31
- }
27
+ } & estree.CallExpression
32
28
  | estree.CatchClause
33
29
  | estree.ChainExpression
34
30
  | estree.ClassBody
@@ -41,37 +37,39 @@ export type AstNode = BaseAstNode & (
41
37
  | estree.EmptyStatement
42
38
  | estree.ExportAllDeclaration
43
39
  | estree.ExportDefaultDeclaration
44
- | estree.ExportNamedDeclaration & {
45
- source?: estree.SimpleLiteral & {
40
+ | {
41
+ source?: {
46
42
  range: [number, number]
47
43
  raw: string
48
44
  value: string
49
- }
45
+ } & estree.SimpleLiteral
50
46
  specifiers: AstNode[]
51
- }
47
+ } & estree.ExportNamedDeclaration
52
48
  | estree.ExportSpecifier
53
49
  | estree.ExpressionStatement
54
50
  | estree.ForInStatement
55
51
  | estree.ForOfStatement
56
52
  | estree.ForStatement
57
- | estree.FunctionDeclaration & {
53
+ | {
58
54
  body: AstNode
55
+ id: AstNode
59
56
  params: AstNode[]
60
- }
61
- | estree.FunctionExpression & {
57
+ } & estree.FunctionDeclaration
58
+ | {
62
59
  body: AstNode
60
+ id?: AstNode
63
61
  params: AstNode[]
64
- }
62
+ } & estree.FunctionExpression
65
63
  | estree.Identifier
66
64
  | estree.IfStatement
67
- | estree.ImportDeclaration & {
68
- source: estree.SimpleLiteral & {
65
+ | {
66
+ source: {
69
67
  range: [number, number]
70
68
  raw: string
71
69
  value: string
72
- }
70
+ } & estree.SimpleLiteral
73
71
  specifiers: AstNode[]
74
- }
72
+ } & estree.ImportDeclaration
75
73
  | estree.ImportDefaultSpecifier
76
74
  | estree.ImportExpression
77
75
  | estree.ImportNamespaceSpecifier
@@ -82,29 +80,34 @@ export type AstNode = BaseAstNode & (
82
80
  | estree.MemberExpression
83
81
  | estree.MetaProperty
84
82
  | estree.MethodDefinition
85
- | estree.NewExpression & {
83
+ | {
86
84
  callee: AstNode
87
85
  arguments: AstNode[]
88
- }
89
- | estree.ObjectExpression & {
86
+ } & estree.NewExpression
87
+ | {
90
88
  properties: AstNode[]
91
- }
92
- | estree.ObjectPattern & {
89
+ } & estree.ObjectExpression
90
+ | {
93
91
  properties: AstNode[]
94
- }
92
+ } & estree.ObjectPattern
95
93
  | estree.PrivateIdentifier
96
94
  | estree.Program
97
- | estree.Property & {
98
- key: AstNode & estree.Identifier
95
+ | {
96
+ key: AstNode & (
97
+ estree.Identifier
98
+ | estree.Literal
99
+ )
99
100
  value: AstNode
100
- }
101
+ } & estree.Property
101
102
  | estree.PropertyDefinition
102
103
  | estree.RestElement
103
104
  | estree.ReturnStatement
104
- | estree.SequenceExpression
105
- | estree.SpreadElement & {
105
+ | {
106
+ expressions: AstNode[]
107
+ } & estree.SequenceExpression
108
+ | {
106
109
  argument: AstNode
107
- }
110
+ } & estree.SpreadElement
108
111
  | estree.StaticBlock
109
112
  | estree.Super
110
113
  | estree.SwitchCase
@@ -118,13 +121,47 @@ export type AstNode = BaseAstNode & (
118
121
  | estree.UnaryExpression
119
122
  | estree.UpdateExpression
120
123
  | estree.VariableDeclaration
121
- | estree.VariableDeclarator & {
124
+ | {
122
125
  id: AstNode
123
126
  init: AstNode
124
- }
127
+ } & estree.VariableDeclarator
125
128
  | estree.WhileStatement
126
129
  | estree.WithStatement
127
130
  | estree.YieldExpression
128
131
  )
129
132
 
130
- export type Comment = BaseAstNode & estree.Comment
133
+ export type BaseAstNode = {
134
+ parent: AstNode
135
+ range: [number, number]
136
+ }
137
+
138
+ export type Comment = BaseAstNode & estree.Comment
139
+
140
+ export type RuleListener = {
141
+ [K in keyof eslint.Rule.NodeListener]: (node: import("../private").AstNode) => void
142
+ }
143
+
144
+ export type RuleOptions = {
145
+ "pretty-imports"?: {
146
+ checkExports?: boolean
147
+ checkImports?: boolean
148
+ indent?: string
149
+ maxLength?: number
150
+ semicolon?: boolean
151
+ }
152
+ "pretty-jsdoc-casting": never
153
+ "pretty-sequence"?: {
154
+ arrayBracketSpacing?: boolean
155
+ checkArray?: boolean
156
+ checkCall?: boolean
157
+ checkObject?: boolean
158
+ checkSequence?: boolean
159
+ funcCallSpacing?: boolean
160
+ indent?: string
161
+ maxLength?: number
162
+ objectCurlySpacing?: boolean
163
+ }
164
+ "svelte-naming-convention"?: {
165
+ fixSameNames?: boolean
166
+ }
167
+ }