@travetto/eslint 7.0.0-rc.1 → 7.0.0-rc.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
CHANGED
|
@@ -36,8 +36,11 @@ process.env.TRV_MANIFEST = './.trv/output/node_modules/@travetto/mono-repo';
|
|
|
36
36
|
const { buildConfig } = require('./.trv/output/node_modules/@travetto/eslint/support/bin/eslint-config.js');
|
|
37
37
|
const { RuntimeIndex } = require('./.trv/output/node_modules/@travetto/runtime/__index__.js');
|
|
38
38
|
|
|
39
|
-
const pluginFiles = RuntimeIndex.find({
|
|
40
|
-
|
|
39
|
+
const pluginFiles = RuntimeIndex.find({
|
|
40
|
+
folder: folder => folder === 'support',
|
|
41
|
+
file: file => /support\/eslint[.]/.test(file.relativeFile)
|
|
42
|
+
});
|
|
43
|
+
const plugins = pluginFiles.map(plugin => require(plugin.outputFile));
|
|
41
44
|
const config = buildConfig(plugins);
|
|
42
45
|
|
|
43
46
|
module.exports = config;
|
|
@@ -109,7 +112,7 @@ export const ImportOrder: TrvEslintPlugin = {
|
|
|
109
112
|
let groupType: (keyof typeof groupTypeMap) | undefined;
|
|
110
113
|
let groupSize = 0;
|
|
111
114
|
let contiguous = false;
|
|
112
|
-
let
|
|
115
|
+
let previous: eslint.AST.Program['body'][number] | undefined;
|
|
113
116
|
|
|
114
117
|
for (const node of body) {
|
|
115
118
|
|
|
@@ -120,13 +123,13 @@ export const ImportOrder: TrvEslintPlugin = {
|
|
|
120
123
|
from = node.source.value;
|
|
121
124
|
}
|
|
122
125
|
} else if (node.type === 'VariableDeclaration' && node.kind === 'const') {
|
|
123
|
-
const [
|
|
126
|
+
const [declaration] = node.declarations;
|
|
124
127
|
let call: Expression | undefined;
|
|
125
|
-
const initType =
|
|
128
|
+
const initType = declaration?.init?.type;
|
|
126
129
|
if (initType === 'CallExpression') {
|
|
127
|
-
call =
|
|
130
|
+
call = declaration.init;
|
|
128
131
|
} else if (initType === 'TSAsExpression') { // tslint support
|
|
129
|
-
call =
|
|
132
|
+
call = declaration.init.expression;
|
|
130
133
|
}
|
|
131
134
|
if (
|
|
132
135
|
call?.type === 'CallExpression' && call.callee.type === 'Identifier' &&
|
|
@@ -155,7 +158,7 @@ export const ImportOrder: TrvEslintPlugin = {
|
|
|
155
158
|
|
|
156
159
|
if (groupType === lineType) {
|
|
157
160
|
groupSize += 1;
|
|
158
|
-
} else if (((node.loc?.end.line ?? 0) - (
|
|
161
|
+
} else if (((node.loc?.end.line ?? 0) - (previous?.loc?.end.line ?? 0)) > 1) {
|
|
159
162
|
// Newlines
|
|
160
163
|
contiguous = false;
|
|
161
164
|
groupSize = 0;
|
|
@@ -172,7 +175,7 @@ export const ImportOrder: TrvEslintPlugin = {
|
|
|
172
175
|
} else { // Contiguous diff, count > 1
|
|
173
176
|
context.report({ message: `Invalid contiguous groups ${groupType} and ${lineType}`, node });
|
|
174
177
|
}
|
|
175
|
-
|
|
178
|
+
previous = node;
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
return { Program: check };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/eslint",
|
|
3
|
-
"version": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.2",
|
|
4
4
|
"description": "ES Linting Rules",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@eslint/js": "^9.35.0",
|
|
28
28
|
"@stylistic/eslint-plugin": "^5.6.1",
|
|
29
|
-
"@travetto/runtime": "^7.0.0-rc.
|
|
29
|
+
"@travetto/runtime": "^7.0.0-rc.2",
|
|
30
30
|
"@types/eslint": "^9.6.1",
|
|
31
31
|
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
|
32
32
|
"@typescript-eslint/parser": "^8.48.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"eslint-plugin-unused-imports": "^4.3.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@travetto/cli": "^7.0.0-rc.
|
|
37
|
+
"@travetto/cli": "^7.0.0-rc.2"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@travetto/cli": {
|
|
@@ -3,8 +3,11 @@ process.env.TRV_MANIFEST = '%MANIFEST_FILE%';
|
|
|
3
3
|
const { buildConfig } = require('@travetto/eslint/support/bin/eslint-config');
|
|
4
4
|
const { RuntimeIndex } = require('@travetto/runtime/__index__');
|
|
5
5
|
|
|
6
|
-
const pluginFiles = RuntimeIndex.find({
|
|
7
|
-
|
|
6
|
+
const pluginFiles = RuntimeIndex.find({
|
|
7
|
+
folder: folder => folder === 'support',
|
|
8
|
+
file: file => /support\/eslint[.]/.test(file.relativeFile)
|
|
9
|
+
});
|
|
10
|
+
const plugins = pluginFiles.map(plugin => require(plugin.outputFile));
|
|
8
11
|
const config = buildConfig(plugins);
|
|
9
12
|
|
|
10
13
|
module.exports = config;
|
|
@@ -3,8 +3,11 @@ process.env.TRV_MANIFEST = '%MANIFEST_FILE%';
|
|
|
3
3
|
const { buildConfig } = await import('@travetto/eslint/support/bin/eslint-config');
|
|
4
4
|
const { RuntimeIndex } = await import('@travetto/runtime/__index__');
|
|
5
5
|
|
|
6
|
-
const pluginFiles = RuntimeIndex.find({
|
|
7
|
-
|
|
6
|
+
const pluginFiles = RuntimeIndex.find({
|
|
7
|
+
folder: folder => folder === 'support',
|
|
8
|
+
file: file => /support\/eslint[.]/.test(file.relativeFile)
|
|
9
|
+
});
|
|
10
|
+
const plugins = await Promise.all(pluginFiles.map(plugin => import(plugin.outputFile)))
|
|
8
11
|
const config = buildConfig(plugins);
|
|
9
12
|
|
|
10
13
|
export default config;
|
|
@@ -17,6 +17,6 @@ export async function buildEslintConfig(): Promise<string> {
|
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
return tpl
|
|
20
|
-
.replace(/'(@travetto\/[^']+)'/g, (_,
|
|
20
|
+
.replace(/'(@travetto\/[^']+)'/g, (_, mod) => `'${RuntimeIndex.resolveFileImport(mod)}'`)
|
|
21
21
|
.replace('%MANIFEST_FILE%', outputPath);
|
|
22
22
|
}
|
|
@@ -38,7 +38,7 @@ export function buildConfig(pluginMaps: Record<string, TrvEslintPlugin>[]): read
|
|
|
38
38
|
rules: tsEslintPlugin.rules,
|
|
39
39
|
},
|
|
40
40
|
'unused-imports': unusedImports,
|
|
41
|
-
...(Object.fromEntries(plugins.map(
|
|
41
|
+
...(Object.fromEntries(plugins.map(plugin => [plugin.name, plugin])))
|
|
42
42
|
},
|
|
43
43
|
rules: {
|
|
44
44
|
...STD_RULES,
|
|
@@ -58,7 +58,7 @@ export function buildConfig(pluginMaps: Record<string, TrvEslintPlugin>[]): read
|
|
|
58
58
|
'unused-imports': unusedImports,
|
|
59
59
|
},
|
|
60
60
|
rules: {
|
|
61
|
-
...Object.fromEntries(Object.entries(STD_RULES).filter(
|
|
61
|
+
...Object.fromEntries(Object.entries(STD_RULES).filter(rule => !rule[0].startsWith('@typescript'))),
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
{
|