From 0bdcb4d0800e0ea02121235182176c3f533c8ec1 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 10 Jun 2025 14:45:34 +0100 Subject: [PATCH] Internationalisation: Properly expose i18n lint rule (#106436) * properlty expose lint rule * don't need types * use rollup plugin copy * fix dist path --- packages/grafana-i18n/package.json | 2 + packages/grafana-i18n/rollup.config.ts | 8 +- scripts/prepare-npm-package.js | 8 ++ yarn.lock | 108 ++++++++++++++++++++++++- 4 files changed, 124 insertions(+), 2 deletions(-) diff --git a/packages/grafana-i18n/package.json b/packages/grafana-i18n/package.json index 4bedfae9dcc..c957cf1ac8f 100644 --- a/packages/grafana-i18n/package.json +++ b/packages/grafana-i18n/package.json @@ -54,6 +54,7 @@ }, "dependencies": { "@formatjs/intl-durationformat": "^0.7.0", + "@typescript-eslint/utils": "^8.33.1", "fast-deep-equal": "^3.1.3", "i18next": "^24.0.0", "i18next-browser-languagedetector": "^8.0.0", @@ -65,6 +66,7 @@ "@grafana/tsconfig": "^2.0.0", "@types/react": "18.3.18", "rollup": "^4.22.4", + "rollup-plugin-copy": "3.5.0", "typescript": "5.7.3" }, "peerDependencies": { diff --git a/packages/grafana-i18n/rollup.config.ts b/packages/grafana-i18n/rollup.config.ts index acdb390d129..e7ad4450725 100644 --- a/packages/grafana-i18n/rollup.config.ts +++ b/packages/grafana-i18n/rollup.config.ts @@ -1,4 +1,5 @@ import { createRequire } from 'node:module'; +import copy from 'rollup-plugin-copy'; import { entryPoint, plugins, esmOutput, cjsOutput, tsDeclarationOutput } from '../rollup.config.parts'; @@ -8,7 +9,12 @@ const pkg = rq('./package.json'); export default [ { input: entryPoint, - plugins, + plugins: [ + ...plugins, + copy({ + targets: [{ src: 'src/eslint', dest: 'dist' }], + }), + ], output: [cjsOutput(pkg), esmOutput(pkg, 'grafana-i18n')], }, tsDeclarationOutput(pkg), diff --git a/scripts/prepare-npm-package.js b/scripts/prepare-npm-package.js index bfbdfcd20b2..fbf9cfdabf6 100644 --- a/scripts/prepare-npm-package.js +++ b/scripts/prepare-npm-package.js @@ -33,6 +33,14 @@ try { }; } + // Fix for @grafana/i18n so eslint-plugin can be imported by consumers + if (pkgJson.content.name === '@grafana/i18n') { + exports['./eslint-plugin'] = { + import: './dist/eslint/index.cjs', + require: './dist/eslint/index.cjs', + }; + } + pkgJson.update({ main: cjsIndex, types: cjsTypes, diff --git a/yarn.lock b/yarn.lock index c79ba25a737..962df61f595 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2198,6 +2198,17 @@ __metadata: languageName: node linkType: hard +"@eslint-community/eslint-utils@npm:^4.7.0": + version: 4.7.0 + resolution: "@eslint-community/eslint-utils@npm:4.7.0" + dependencies: + eslint-visitor-keys: "npm:^3.4.3" + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + checksum: 10/43ed5d391526d9f5bbe452aef336389a473026fca92057cf97c576db11401ce9bcf8ef0bf72625bbaf6207ed8ba6bf0dcf4d7e809c24f08faa68a28533c491a7 + languageName: node + linkType: hard + "@eslint-community/regexpp@npm:^4.10.0, @eslint-community/regexpp@npm:^4.12.1": version: 4.12.1 resolution: "@eslint-community/regexpp@npm:4.12.1" @@ -3176,6 +3187,7 @@ __metadata: "@formatjs/intl-durationformat": "npm:^0.7.0" "@grafana/tsconfig": "npm:^2.0.0" "@types/react": "npm:18.3.18" + "@typescript-eslint/utils": "npm:^8.33.1" fast-deep-equal: "npm:^3.1.3" i18next: "npm:^24.0.0" i18next-browser-languagedetector: "npm:^8.0.0" @@ -3183,6 +3195,7 @@ __metadata: micro-memoize: "npm:^4.1.2" react-i18next: "npm:^15.0.0" rollup: "npm:^4.22.4" + rollup-plugin-copy: "npm:3.5.0" typescript: "npm:5.7.3" peerDependencies: react: ">=18" @@ -10186,6 +10199,19 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/project-service@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/project-service@npm:8.33.1" + dependencies: + "@typescript-eslint/tsconfig-utils": "npm:^8.33.1" + "@typescript-eslint/types": "npm:^8.33.1" + debug: "npm:^4.3.4" + peerDependencies: + typescript: ">=4.8.4 <5.9.0" + checksum: 10/c166e21f305eb798ce135477a1ce78e7fac040b597e0acb2e3ecca84380af2aeb4242944dc201bc611aa14f04dd4af0d123d9cf252f7fe39b0a7e158326f705d + languageName: node + linkType: hard + "@typescript-eslint/scope-manager@npm:5.62.0": version: 5.62.0 resolution: "@typescript-eslint/scope-manager@npm:5.62.0" @@ -10206,6 +10232,25 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/scope-manager@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/scope-manager@npm:8.33.1" + dependencies: + "@typescript-eslint/types": "npm:8.33.1" + "@typescript-eslint/visitor-keys": "npm:8.33.1" + checksum: 10/a513fa79eef269a4f3d031cd1fddbb15c793e3efd6b6b64a6ae85ea0fea03570feffdc071e2bbe9241680d23d8a4ca6d63a998e34c2a24dbe185cd509ee2f9cb + languageName: node + linkType: hard + +"@typescript-eslint/tsconfig-utils@npm:8.33.1, @typescript-eslint/tsconfig-utils@npm:^8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/tsconfig-utils@npm:8.33.1" + peerDependencies: + typescript: ">=4.8.4 <5.9.0" + checksum: 10/9e0e348af4d54b7e42a015bf36e08965c8fa389ac7b179c2ccf2bec5fce4b31e951397394dcbaea6fb0ddf782f4f2f2ee71df108173742f756705f82d653cc9d + languageName: node + linkType: hard + "@typescript-eslint/type-utils@npm:8.22.0": version: 8.22.0 resolution: "@typescript-eslint/type-utils@npm:8.22.0" @@ -10235,6 +10280,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:8.33.1, @typescript-eslint/types@npm:^8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/types@npm:8.33.1" + checksum: 10/27bee01122366438ada7919f91f479fec75e23e2f8033e7e74a12dcfeaa2c28a72e83c545bb676be4369c983b3da5eec101cffb431c52abcc2b6664b48255147 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:5.62.0": version: 5.62.0 resolution: "@typescript-eslint/typescript-estree@npm:5.62.0" @@ -10271,6 +10323,26 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/typescript-estree@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/typescript-estree@npm:8.33.1" + dependencies: + "@typescript-eslint/project-service": "npm:8.33.1" + "@typescript-eslint/tsconfig-utils": "npm:8.33.1" + "@typescript-eslint/types": "npm:8.33.1" + "@typescript-eslint/visitor-keys": "npm:8.33.1" + debug: "npm:^4.3.4" + fast-glob: "npm:^3.3.2" + is-glob: "npm:^4.0.3" + minimatch: "npm:^9.0.4" + semver: "npm:^7.6.0" + ts-api-utils: "npm:^2.1.0" + peerDependencies: + typescript: ">=4.8.4 <5.9.0" + checksum: 10/2876b66acd72f8a1093f8671e05015554fea736d492dbc83084f74faff71d40d66a96452396272252f5e36c1dab2082679d10c7b8aca9f3e2f1b6084afeef807 + languageName: node + linkType: hard + "@typescript-eslint/utils@npm:8.22.0, @typescript-eslint/utils@npm:^6.0.0 || ^7.0.0 || ^8.0.0, @typescript-eslint/utils@npm:^8.13.0, @typescript-eslint/utils@npm:^8.15.0, @typescript-eslint/utils@npm:^8.9.0": version: 8.22.0 resolution: "@typescript-eslint/utils@npm:8.22.0" @@ -10304,6 +10376,21 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/utils@npm:^8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/utils@npm:8.33.1" + dependencies: + "@eslint-community/eslint-utils": "npm:^4.7.0" + "@typescript-eslint/scope-manager": "npm:8.33.1" + "@typescript-eslint/types": "npm:8.33.1" + "@typescript-eslint/typescript-estree": "npm:8.33.1" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + typescript: ">=4.8.4 <5.9.0" + checksum: 10/ba76f25b178e2b3280d7aad8becf6a1edd3c57f76f36e6a22d951207282ecc8bfce831ed2f2dd95a70637dcfea2932b3d0a39ac19dd8f9881502738464c6179a + languageName: node + linkType: hard + "@typescript-eslint/visitor-keys@npm:5.62.0": version: 5.62.0 resolution: "@typescript-eslint/visitor-keys@npm:5.62.0" @@ -10324,6 +10411,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:8.33.1": + version: 8.33.1 + resolution: "@typescript-eslint/visitor-keys@npm:8.33.1" + dependencies: + "@typescript-eslint/types": "npm:8.33.1" + eslint-visitor-keys: "npm:^4.2.0" + checksum: 10/8c1ba7373d8d47d2f2183355db278d4042ecdf268a898c5f4736d84aaa716c6b6faf354247eff8dc1337a7f64168f02e34f3781994d11e9fa8c2b0e35c652c49 + languageName: node + linkType: hard + "@visx/bounds@npm:3.12.0": version: 3.12.0 resolution: "@visx/bounds@npm:3.12.0" @@ -15972,7 +16069,7 @@ __metadata: languageName: node linkType: hard -"eslint-visitor-keys@npm:^3.3.0": +"eslint-visitor-keys@npm:^3.3.0, eslint-visitor-keys@npm:^3.4.3": version: 3.4.3 resolution: "eslint-visitor-keys@npm:3.4.3" checksum: 10/3f357c554a9ea794b094a09bd4187e5eacd1bc0d0653c3adeb87962c548e6a1ab8f982b86963ae1337f5d976004146536dcee5d0e2806665b193fbfbf1a9231b @@ -30195,6 +30292,15 @@ __metadata: languageName: node linkType: hard +"ts-api-utils@npm:^2.1.0": + version: 2.1.0 + resolution: "ts-api-utils@npm:2.1.0" + peerDependencies: + typescript: ">=4.8.4" + checksum: 10/02e55b49d9617c6eebf8aadfa08d3ca03ca0cd2f0586ad34117fdfc7aa3cd25d95051843fde9df86665ad907f99baed179e7a117b11021417f379e4d2614eacd + languageName: node + linkType: hard + "ts-dedent@npm:^2.0.0": version: 2.2.0 resolution: "ts-dedent@npm:2.2.0"