@grafana/create-plugin 6.4.2 → 6.4.3
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/CHANGELOG.md +14 -0
- package/dist/codemods/migrations/scripts/004-eslint9-flat-config.js +3 -2
- package/package.json +2 -2
- package/src/codemods/migrations/scripts/004-eslint9-flat-config.test.ts +86 -7
- package/src/codemods/migrations/scripts/004-eslint9-flat-config.ts +3 -2
- package/templates/common/_package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# v6.4.3 (Fri Dec 05 2025)
|
|
2
|
+
|
|
3
|
+
#### 🐛 Bug Fix
|
|
4
|
+
|
|
5
|
+
- fix: only migrate eslint if plugin depends on eslint < 9.0.0 [#2338](https://github.com/grafana/plugin-tools/pull/2338) ([@jackw](https://github.com/jackw))
|
|
6
|
+
- Update dependency @grafana/plugin-e2e to v3.0.3 [#2335](https://github.com/grafana/plugin-tools/pull/2335) ([@renovate-sh-app[bot]](https://github.com/renovate-sh-app[bot]))
|
|
7
|
+
|
|
8
|
+
#### Authors: 2
|
|
9
|
+
|
|
10
|
+
- [@renovate-sh-app[bot]](https://github.com/renovate-sh-app[bot])
|
|
11
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
1
15
|
# v6.4.2 (Thu Nov 27 2025)
|
|
2
16
|
|
|
3
17
|
#### 🐛 Bug Fix
|
|
@@ -4,7 +4,7 @@ import { parse } from 'jsonc-parser';
|
|
|
4
4
|
import minimist from 'minimist';
|
|
5
5
|
import { resolve, dirname, relative } from 'node:path';
|
|
6
6
|
import * as recast from 'recast';
|
|
7
|
-
import { addDependenciesToPackageJson, migrationsDebug } from '../../utils.js';
|
|
7
|
+
import { isVersionGreater, addDependenciesToPackageJson, migrationsDebug } from '../../utils.js';
|
|
8
8
|
|
|
9
9
|
const { builders } = recast.types;
|
|
10
10
|
const legacyKeysToCopy = ["rules", "settings"];
|
|
@@ -18,7 +18,8 @@ const devDependenciesToUpdate = {
|
|
|
18
18
|
"eslint-webpack-plugin": "^5.0.0"
|
|
19
19
|
};
|
|
20
20
|
function migrate(context) {
|
|
21
|
-
const
|
|
21
|
+
const packageJson = JSON.parse(context.getFile("package.json") || "");
|
|
22
|
+
const needsMigration = isVersionGreater(devDependenciesToUpdate.eslint, packageJson.devDependencies?.eslint);
|
|
22
23
|
if (!needsMigration) {
|
|
23
24
|
return context;
|
|
24
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"directory": "packages/create-plugin",
|
|
6
6
|
"url": "https://github.com/grafana/plugin-tools"
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=20"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "89b6bb2341555a8f965c88e5af71fa5bbc16537c"
|
|
60
60
|
}
|
|
@@ -2,9 +2,22 @@ import migrate from './004-eslint9-flat-config.js';
|
|
|
2
2
|
import { Context } from '../../context.js';
|
|
3
3
|
|
|
4
4
|
describe('004-eslint9-flat-config', () => {
|
|
5
|
+
let context: Context;
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
context = new Context('/virtual');
|
|
9
|
+
});
|
|
10
|
+
|
|
5
11
|
describe('migration', () => {
|
|
6
12
|
it('should migrate default create-plugin scaffolded configs', async () => {
|
|
7
|
-
|
|
13
|
+
context.addFile(
|
|
14
|
+
'package.json',
|
|
15
|
+
JSON.stringify({
|
|
16
|
+
devDependencies: {
|
|
17
|
+
eslint: '^8.0.0',
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
);
|
|
8
21
|
context.addFile('.eslintrc', JSON.stringify({ extends: ['./.config/.eslintrc'] }));
|
|
9
22
|
context.addFile(
|
|
10
23
|
'.config/.eslintrc',
|
|
@@ -73,11 +86,15 @@ describe('004-eslint9-flat-config', () => {
|
|
|
73
86
|
});
|
|
74
87
|
|
|
75
88
|
it('should migrate legacy eslint config with ignore patterns', async () => {
|
|
76
|
-
const context = new Context('/virtual');
|
|
77
89
|
context.addFile('.eslintrc', JSON.stringify({ rules: { 'no-console': 'error' } }));
|
|
78
90
|
context.addFile(
|
|
79
91
|
'package.json',
|
|
80
|
-
JSON.stringify({
|
|
92
|
+
JSON.stringify({
|
|
93
|
+
scripts: { lint: 'eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .' },
|
|
94
|
+
devDependencies: {
|
|
95
|
+
eslint: '^8.0.0',
|
|
96
|
+
},
|
|
97
|
+
})
|
|
81
98
|
);
|
|
82
99
|
context.addFile('.eslintignore', '*.test.ts');
|
|
83
100
|
context.addFile('.gitignore', ['.github', '.vscode', 'playwright-report', '**/dist'].join('\n'));
|
|
@@ -103,8 +120,14 @@ describe('004-eslint9-flat-config', () => {
|
|
|
103
120
|
});
|
|
104
121
|
|
|
105
122
|
it('should attempt to migrate eslint configs with extends, plugins, rules, and overrides', async () => {
|
|
106
|
-
|
|
107
|
-
|
|
123
|
+
context.addFile(
|
|
124
|
+
'package.json',
|
|
125
|
+
JSON.stringify({
|
|
126
|
+
devDependencies: {
|
|
127
|
+
eslint: '^8.0.0',
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
);
|
|
108
131
|
context.addFile(
|
|
109
132
|
'.eslintrc',
|
|
110
133
|
JSON.stringify(
|
|
@@ -165,7 +188,6 @@ describe('004-eslint9-flat-config', () => {
|
|
|
165
188
|
});
|
|
166
189
|
|
|
167
190
|
it('should update package.json scripts and devDependencies', async () => {
|
|
168
|
-
const context = new Context('/virtual');
|
|
169
191
|
context.addFile(
|
|
170
192
|
'package.json',
|
|
171
193
|
JSON.stringify({
|
|
@@ -217,7 +239,14 @@ describe('004-eslint9-flat-config', () => {
|
|
|
217
239
|
});
|
|
218
240
|
|
|
219
241
|
it('should not make additional changes when run multiple times', async () => {
|
|
220
|
-
|
|
242
|
+
context.addFile(
|
|
243
|
+
'package.json',
|
|
244
|
+
JSON.stringify({
|
|
245
|
+
devDependencies: {
|
|
246
|
+
eslint: '^8.0.0',
|
|
247
|
+
},
|
|
248
|
+
})
|
|
249
|
+
);
|
|
221
250
|
context.addFile('.eslintrc', JSON.stringify({ extends: ['./.config/.eslintrc'] }));
|
|
222
251
|
context.addFile(
|
|
223
252
|
'.config/.eslintrc',
|
|
@@ -226,5 +255,55 @@ describe('004-eslint9-flat-config', () => {
|
|
|
226
255
|
|
|
227
256
|
await expect(migrate).toBeIdempotent(context);
|
|
228
257
|
});
|
|
258
|
+
|
|
259
|
+
it('should not migrate when eslint version is already at target version', async () => {
|
|
260
|
+
const originalPackageJson = JSON.stringify({
|
|
261
|
+
devDependencies: {
|
|
262
|
+
eslint: '^9.0.0',
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
context.addFile('package.json', originalPackageJson);
|
|
266
|
+
context.addFile('.eslintrc', JSON.stringify({ extends: ['@grafana/eslint-config'] }));
|
|
267
|
+
|
|
268
|
+
const result = await migrate(context);
|
|
269
|
+
|
|
270
|
+
// Migration should not run - no flat config created, legacy config remains, package.json unchanged
|
|
271
|
+
expect(result.getFile('eslint.config.mjs')).toBeUndefined();
|
|
272
|
+
expect(result.getFile('.eslintrc')).toBeDefined();
|
|
273
|
+
expect(result.getFile('package.json')).toEqual(originalPackageJson);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('should not migrate when eslint version is newer than target version', async () => {
|
|
277
|
+
const originalPackageJson = JSON.stringify({
|
|
278
|
+
devDependencies: {
|
|
279
|
+
eslint: '^10.0.0',
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
context.addFile('package.json', originalPackageJson);
|
|
283
|
+
context.addFile('.eslintrc', JSON.stringify({ extends: ['@grafana/eslint-config'] }));
|
|
284
|
+
|
|
285
|
+
const result = await migrate(context);
|
|
286
|
+
|
|
287
|
+
// Migration should not run - no flat config created, legacy config remains, package.json unchanged
|
|
288
|
+
expect(result.getFile('eslint.config.mjs')).toBeUndefined();
|
|
289
|
+
expect(result.getFile('.eslintrc')).toBeDefined();
|
|
290
|
+
expect(result.getFile('package.json')).toEqual(originalPackageJson);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('should migrate when eslint version is older than target version', async () => {
|
|
294
|
+
context.addFile(
|
|
295
|
+
'package.json',
|
|
296
|
+
JSON.stringify({
|
|
297
|
+
devDependencies: {
|
|
298
|
+
eslint: '^8.57.0',
|
|
299
|
+
},
|
|
300
|
+
})
|
|
301
|
+
);
|
|
302
|
+
context.addFile('.eslintrc', JSON.stringify({ extends: ['@grafana/eslint-config'] }));
|
|
303
|
+
|
|
304
|
+
const result = await migrate(context);
|
|
305
|
+
expect(result.getFile('eslint.config.mjs')).toBeDefined();
|
|
306
|
+
expect(result.getFile('.eslintrc')).toBeUndefined();
|
|
307
|
+
});
|
|
229
308
|
});
|
|
230
309
|
});
|
|
@@ -6,7 +6,7 @@ import minimist from 'minimist';
|
|
|
6
6
|
import { dirname, relative, resolve } from 'node:path';
|
|
7
7
|
import * as recast from 'recast';
|
|
8
8
|
import type { Context } from '../../context.js';
|
|
9
|
-
import { addDependenciesToPackageJson, migrationsDebug } from '../../utils.js';
|
|
9
|
+
import { addDependenciesToPackageJson, isVersionGreater, migrationsDebug } from '../../utils.js';
|
|
10
10
|
|
|
11
11
|
type Imports = Map<string, { name?: string; bindings?: string[] }>;
|
|
12
12
|
|
|
@@ -23,7 +23,8 @@ const devDependenciesToUpdate = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export default function migrate(context: Context): Context {
|
|
26
|
-
const
|
|
26
|
+
const packageJson = JSON.parse(context.getFile('package.json') || '');
|
|
27
|
+
const needsMigration = isVersionGreater(devDependenciesToUpdate.eslint, packageJson.devDependencies?.eslint);
|
|
27
28
|
if (!needsMigration) {
|
|
28
29
|
return context;
|
|
29
30
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@grafana/eslint-config": "^9.0.0",
|
|
20
|
-
"@grafana/plugin-e2e": "^3.0.
|
|
20
|
+
"@grafana/plugin-e2e": "^3.0.3",
|
|
21
21
|
"@grafana/tsconfig": "^2.0.1",
|
|
22
22
|
"@playwright/test": "^1.52.0",{{#if useExperimentalRspack}}
|
|
23
23
|
"@rspack/core": "^1.3.0",
|