eslint-plugin-kirklin 0.1.7 → 0.1.9

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2019-PRESENT Kirk Lin<https://github.com/kirklin>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2019-PRESENT Kirk Lin<https://github.com/kirklin>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -25,10 +25,12 @@ const ifNewline = createEslintRule({
25
25
  create: (context) => {
26
26
  return {
27
27
  IfStatement(node) {
28
- if (!node.consequent)
28
+ if (!node.consequent) {
29
29
  return;
30
- if (node.consequent.type === "BlockStatement")
30
+ }
31
+ if (node.consequent.type === "BlockStatement") {
31
32
  return;
33
+ }
32
34
  if (node.test.loc.end.line === node.consequent.loc.start.line) {
33
35
  context.report({
34
36
  node,
@@ -66,8 +68,9 @@ const importDedupe = createEslintRule({
66
68
  create: (context) => {
67
69
  return {
68
70
  ImportDeclaration(node) {
69
- if (node.specifiers.length <= 1)
71
+ if (node.specifiers.length <= 1) {
70
72
  return;
73
+ }
71
74
  const names = /* @__PURE__ */ new Set();
72
75
  node.specifiers.forEach((n) => {
73
76
  const id = n.local.name;
@@ -82,8 +85,9 @@ const importDedupe = createEslintRule({
82
85
  fix(fixer) {
83
86
  const s = n.range[0];
84
87
  let e = n.range[1];
85
- if (context.getSourceCode().text[e] === ",")
88
+ if (context.getSourceCode().text[e] === ",") {
86
89
  e += 1;
90
+ }
87
91
  return fixer.removeRange([s, e]);
88
92
  }
89
93
  });
@@ -115,14 +119,16 @@ const preferInlineTypeImport = createEslintRule({
115
119
  const sourceCode = context.getSourceCode();
116
120
  return {
117
121
  ImportDeclaration: (node) => {
118
- if (node.specifiers.length === 1 && ["ImportNamespaceSpecifier", "ImportDefaultSpecifier"].includes(node.specifiers[0].type))
122
+ if (node.specifiers.length === 1 && ["ImportNamespaceSpecifier", "ImportDefaultSpecifier"].includes(node.specifiers[0].type)) {
119
123
  return;
124
+ }
120
125
  if (node.importKind === "type") {
121
126
  context.report({
122
127
  *fix(fixer) {
123
128
  yield* removeTypeSpecifier(fixer, sourceCode, node);
124
- for (const specifier of node.specifiers)
129
+ for (const specifier of node.specifiers) {
125
130
  yield fixer.insertTextBefore(specifier, "type ");
131
+ }
126
132
  },
127
133
  loc: node.loc,
128
134
  messageId: "preferInlineTypeImport",
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- declare const _default: {
2
- rules: {
3
- "if-newline": any;
4
- "import-dedupe": any;
5
- "prefer-inline-type-import": any;
6
- };
1
+ import * as _typescript_eslint_utils_dist_ts_eslint_Rule from '@typescript-eslint/utils/dist/ts-eslint/Rule';
2
+
3
+ declare const _default: {
4
+ rules: {
5
+ "if-newline": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"missingIfNewline", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
6
+ "import-dedupe": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"importDedupe", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
7
+ "prefer-inline-type-import": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"preferInlineTypeImport", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
8
+ };
7
9
  };
8
10
 
9
11
  export { _default as default };
package/dist/index.mjs CHANGED
@@ -23,10 +23,12 @@ const ifNewline = createEslintRule({
23
23
  create: (context) => {
24
24
  return {
25
25
  IfStatement(node) {
26
- if (!node.consequent)
26
+ if (!node.consequent) {
27
27
  return;
28
- if (node.consequent.type === "BlockStatement")
28
+ }
29
+ if (node.consequent.type === "BlockStatement") {
29
30
  return;
31
+ }
30
32
  if (node.test.loc.end.line === node.consequent.loc.start.line) {
31
33
  context.report({
32
34
  node,
@@ -64,8 +66,9 @@ const importDedupe = createEslintRule({
64
66
  create: (context) => {
65
67
  return {
66
68
  ImportDeclaration(node) {
67
- if (node.specifiers.length <= 1)
69
+ if (node.specifiers.length <= 1) {
68
70
  return;
71
+ }
69
72
  const names = /* @__PURE__ */ new Set();
70
73
  node.specifiers.forEach((n) => {
71
74
  const id = n.local.name;
@@ -80,8 +83,9 @@ const importDedupe = createEslintRule({
80
83
  fix(fixer) {
81
84
  const s = n.range[0];
82
85
  let e = n.range[1];
83
- if (context.getSourceCode().text[e] === ",")
86
+ if (context.getSourceCode().text[e] === ",") {
84
87
  e += 1;
88
+ }
85
89
  return fixer.removeRange([s, e]);
86
90
  }
87
91
  });
@@ -113,14 +117,16 @@ const preferInlineTypeImport = createEslintRule({
113
117
  const sourceCode = context.getSourceCode();
114
118
  return {
115
119
  ImportDeclaration: (node) => {
116
- if (node.specifiers.length === 1 && ["ImportNamespaceSpecifier", "ImportDefaultSpecifier"].includes(node.specifiers[0].type))
120
+ if (node.specifiers.length === 1 && ["ImportNamespaceSpecifier", "ImportDefaultSpecifier"].includes(node.specifiers[0].type)) {
117
121
  return;
122
+ }
118
123
  if (node.importKind === "type") {
119
124
  context.report({
120
125
  *fix(fixer) {
121
126
  yield* removeTypeSpecifier(fixer, sourceCode, node);
122
- for (const specifier of node.specifiers)
127
+ for (const specifier of node.specifiers) {
123
128
  yield fixer.insertTextBefore(specifier, "type ");
129
+ }
124
130
  },
125
131
  loc: node.loc,
126
132
  messageId: "preferInlineTypeImport",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-kirklin",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/kirklin/eslint-config",
6
6
  "main": "./dist/index.cjs",