@so1ve/eslint-plugin 0.69.1 → 0.71.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/dist/index.cjs +53 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +53 -9
- package/package.json +4 -7
package/dist/index.cjs
CHANGED
|
@@ -4,9 +4,9 @@ const utils = require('@typescript-eslint/utils');
|
|
|
4
4
|
|
|
5
5
|
const createEslintRule = utils.ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
6
6
|
|
|
7
|
-
const RULE_NAME$
|
|
7
|
+
const RULE_NAME$4 = "import-dedupe";
|
|
8
8
|
const importDedupe = createEslintRule({
|
|
9
|
-
name: RULE_NAME$
|
|
9
|
+
name: RULE_NAME$4,
|
|
10
10
|
meta: {
|
|
11
11
|
type: "problem",
|
|
12
12
|
docs: {
|
|
@@ -54,9 +54,9 @@ const importDedupe = createEslintRule({
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
const RULE_NAME$
|
|
57
|
+
const RULE_NAME$3 = "no-inline-type-import";
|
|
58
58
|
const noInlineTypeImport = createEslintRule({
|
|
59
|
-
name: RULE_NAME$
|
|
59
|
+
name: RULE_NAME$3,
|
|
60
60
|
meta: {
|
|
61
61
|
type: "layout",
|
|
62
62
|
docs: {
|
|
@@ -106,9 +106,9 @@ import { ${valueSpecifiersText} } from "${node.source.value}";`
|
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
const RULE_NAME$
|
|
109
|
+
const RULE_NAME$2 = "no-useless-template-string";
|
|
110
110
|
const noUselessTemplateString = createEslintRule({
|
|
111
|
-
name: RULE_NAME$
|
|
111
|
+
name: RULE_NAME$2,
|
|
112
112
|
meta: {
|
|
113
113
|
type: "problem",
|
|
114
114
|
docs: {
|
|
@@ -142,9 +142,9 @@ const noUselessTemplateString = createEslintRule({
|
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
-
const RULE_NAME = "pad-after-last-import";
|
|
145
|
+
const RULE_NAME$1 = "pad-after-last-import";
|
|
146
146
|
const padAfterLastImport = createEslintRule({
|
|
147
|
-
name: RULE_NAME,
|
|
147
|
+
name: RULE_NAME$1,
|
|
148
148
|
meta: {
|
|
149
149
|
type: "problem",
|
|
150
150
|
docs: {
|
|
@@ -168,7 +168,8 @@ const padAfterLastImport = createEslintRule({
|
|
|
168
168
|
"Program:exit"() {
|
|
169
169
|
if (lastImportNode) {
|
|
170
170
|
const nextToken = sourceCode.getTokenAfter(lastImportNode);
|
|
171
|
-
if (nextToken &&
|
|
171
|
+
if (nextToken && // Workaround: Vue
|
|
172
|
+
nextToken.value !== "<\/script>" && lastImportNode.loc.end.line + 1 === nextToken.loc.start.line) {
|
|
172
173
|
context.report({
|
|
173
174
|
node: lastImportNode,
|
|
174
175
|
messageId: "padAfterLastImport",
|
|
@@ -181,11 +182,54 @@ const padAfterLastImport = createEslintRule({
|
|
|
181
182
|
}
|
|
182
183
|
});
|
|
183
184
|
|
|
185
|
+
const RULE_NAME = "no-beginning-newline";
|
|
186
|
+
const noBeginningNewline = createEslintRule({
|
|
187
|
+
name: RULE_NAME,
|
|
188
|
+
meta: {
|
|
189
|
+
type: "layout",
|
|
190
|
+
docs: {
|
|
191
|
+
description: "No beginning newline",
|
|
192
|
+
recommended: "error"
|
|
193
|
+
},
|
|
194
|
+
fixable: "whitespace",
|
|
195
|
+
schema: [],
|
|
196
|
+
messages: {
|
|
197
|
+
noBeginningNewline: "No beginning newline"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
defaultOptions: [],
|
|
201
|
+
create: (context) => {
|
|
202
|
+
const text = context.getSourceCode().text;
|
|
203
|
+
return {
|
|
204
|
+
Program: (node) => {
|
|
205
|
+
const newlines = text.match(/([\n]*)/)[1];
|
|
206
|
+
if (newlines.length > 0) {
|
|
207
|
+
context.report({
|
|
208
|
+
node,
|
|
209
|
+
loc: {
|
|
210
|
+
start: {
|
|
211
|
+
line: 0,
|
|
212
|
+
column: 0
|
|
213
|
+
},
|
|
214
|
+
end: node.loc.start
|
|
215
|
+
},
|
|
216
|
+
messageId: "noBeginningNewline",
|
|
217
|
+
*fix(fixer) {
|
|
218
|
+
yield fixer.removeRange([0, node.range[0]]);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
184
227
|
const index = {
|
|
185
228
|
rules: {
|
|
186
229
|
"import-dedupe": importDedupe,
|
|
187
230
|
"no-inline-type-import": noInlineTypeImport,
|
|
188
231
|
"no-useless-template-string": noUselessTemplateString,
|
|
232
|
+
"no-beginning-newline": noBeginningNewline,
|
|
189
233
|
"pad-after-last-import": padAfterLastImport
|
|
190
234
|
}
|
|
191
235
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare const _default: {
|
|
|
5
5
|
"import-dedupe": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"importDedupe", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
6
6
|
"no-inline-type-import": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noInlineTypeImport", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
7
7
|
"no-useless-template-string": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noUselessTemplateString", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
8
|
+
"no-beginning-newline": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noBeginningNewline", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
8
9
|
"pad-after-last-import": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"padAfterLastImport", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
9
10
|
};
|
|
10
11
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
2
2
|
|
|
3
3
|
const createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
4
4
|
|
|
5
|
-
const RULE_NAME$
|
|
5
|
+
const RULE_NAME$4 = "import-dedupe";
|
|
6
6
|
const importDedupe = createEslintRule({
|
|
7
|
-
name: RULE_NAME$
|
|
7
|
+
name: RULE_NAME$4,
|
|
8
8
|
meta: {
|
|
9
9
|
type: "problem",
|
|
10
10
|
docs: {
|
|
@@ -52,9 +52,9 @@ const importDedupe = createEslintRule({
|
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
const RULE_NAME$
|
|
55
|
+
const RULE_NAME$3 = "no-inline-type-import";
|
|
56
56
|
const noInlineTypeImport = createEslintRule({
|
|
57
|
-
name: RULE_NAME$
|
|
57
|
+
name: RULE_NAME$3,
|
|
58
58
|
meta: {
|
|
59
59
|
type: "layout",
|
|
60
60
|
docs: {
|
|
@@ -104,9 +104,9 @@ import { ${valueSpecifiersText} } from "${node.source.value}";`
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
const RULE_NAME$
|
|
107
|
+
const RULE_NAME$2 = "no-useless-template-string";
|
|
108
108
|
const noUselessTemplateString = createEslintRule({
|
|
109
|
-
name: RULE_NAME$
|
|
109
|
+
name: RULE_NAME$2,
|
|
110
110
|
meta: {
|
|
111
111
|
type: "problem",
|
|
112
112
|
docs: {
|
|
@@ -140,9 +140,9 @@ const noUselessTemplateString = createEslintRule({
|
|
|
140
140
|
}
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
const RULE_NAME = "pad-after-last-import";
|
|
143
|
+
const RULE_NAME$1 = "pad-after-last-import";
|
|
144
144
|
const padAfterLastImport = createEslintRule({
|
|
145
|
-
name: RULE_NAME,
|
|
145
|
+
name: RULE_NAME$1,
|
|
146
146
|
meta: {
|
|
147
147
|
type: "problem",
|
|
148
148
|
docs: {
|
|
@@ -166,7 +166,8 @@ const padAfterLastImport = createEslintRule({
|
|
|
166
166
|
"Program:exit"() {
|
|
167
167
|
if (lastImportNode) {
|
|
168
168
|
const nextToken = sourceCode.getTokenAfter(lastImportNode);
|
|
169
|
-
if (nextToken &&
|
|
169
|
+
if (nextToken && // Workaround: Vue
|
|
170
|
+
nextToken.value !== "<\/script>" && lastImportNode.loc.end.line + 1 === nextToken.loc.start.line) {
|
|
170
171
|
context.report({
|
|
171
172
|
node: lastImportNode,
|
|
172
173
|
messageId: "padAfterLastImport",
|
|
@@ -179,11 +180,54 @@ const padAfterLastImport = createEslintRule({
|
|
|
179
180
|
}
|
|
180
181
|
});
|
|
181
182
|
|
|
183
|
+
const RULE_NAME = "no-beginning-newline";
|
|
184
|
+
const noBeginningNewline = createEslintRule({
|
|
185
|
+
name: RULE_NAME,
|
|
186
|
+
meta: {
|
|
187
|
+
type: "layout",
|
|
188
|
+
docs: {
|
|
189
|
+
description: "No beginning newline",
|
|
190
|
+
recommended: "error"
|
|
191
|
+
},
|
|
192
|
+
fixable: "whitespace",
|
|
193
|
+
schema: [],
|
|
194
|
+
messages: {
|
|
195
|
+
noBeginningNewline: "No beginning newline"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
defaultOptions: [],
|
|
199
|
+
create: (context) => {
|
|
200
|
+
const text = context.getSourceCode().text;
|
|
201
|
+
return {
|
|
202
|
+
Program: (node) => {
|
|
203
|
+
const newlines = text.match(/([\n]*)/)[1];
|
|
204
|
+
if (newlines.length > 0) {
|
|
205
|
+
context.report({
|
|
206
|
+
node,
|
|
207
|
+
loc: {
|
|
208
|
+
start: {
|
|
209
|
+
line: 0,
|
|
210
|
+
column: 0
|
|
211
|
+
},
|
|
212
|
+
end: node.loc.start
|
|
213
|
+
},
|
|
214
|
+
messageId: "noBeginningNewline",
|
|
215
|
+
*fix(fixer) {
|
|
216
|
+
yield fixer.removeRange([0, node.range[0]]);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
182
225
|
const index = {
|
|
183
226
|
rules: {
|
|
184
227
|
"import-dedupe": importDedupe,
|
|
185
228
|
"no-inline-type-import": noInlineTypeImport,
|
|
186
229
|
"no-useless-template-string": noUselessTemplateString,
|
|
230
|
+
"no-beginning-newline": noBeginningNewline,
|
|
187
231
|
"pad-after-last-import": padAfterLastImport
|
|
188
232
|
}
|
|
189
233
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@so1ve/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.71.0",
|
|
4
4
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -32,17 +32,14 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@typescript-eslint/utils": "^5.58.0",
|
|
35
|
-
"@vue/reactivity": "^3.2.47"
|
|
36
|
-
"eslint-define-config": "^1.18.0"
|
|
35
|
+
"@vue/reactivity": "^3.2.47"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
38
|
"@types/node": "^18.15.11",
|
|
40
|
-
"@typescript-eslint/types": "^5.58.0"
|
|
41
|
-
"unbuild": "^1.2.1",
|
|
42
|
-
"vitest": "^0.30.1"
|
|
39
|
+
"@typescript-eslint/types": "^5.58.0"
|
|
43
40
|
},
|
|
44
41
|
"scripts": {
|
|
45
|
-
"build": "
|
|
42
|
+
"build": "unbuild",
|
|
46
43
|
"stub": "unbuild --stub",
|
|
47
44
|
"test": "vitest"
|
|
48
45
|
}
|