Chore: Prevent direct path imports from workspace grafana packages (#98940)

* restrict imports from @grafana/ui/src paths

* prevent path imports from all grafana packages

* just run on ui, runtime, data packages

* update
This commit is contained in:
Josh Hunt 2025-01-15 13:47:44 +00:00 committed by GitHub
parent 1dcff0a71f
commit e3e580edfa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 970 additions and 304 deletions

View File

@ -86,6 +86,10 @@ module.exports = [
importNames: ['Layout', 'HorizontalGroup', 'VerticalGroup'], importNames: ['Layout', 'HorizontalGroup', 'VerticalGroup'],
message: 'Use Stack component instead.', message: 'Use Stack component instead.',
}, },
{
group: ['@grafana/ui/src/*', '@grafana/runtime/src/*', '@grafana/data/src/*'],
message: 'Import from the public export instead.',
},
], ],
}, },
], ],

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
// @ts-check
const { parse } = require('ini'); const { parse } = require('ini');
const { readFileSync, existsSync } = require('node:fs'); const { readFileSync, existsSync } = require('node:fs');
const path = require('path'); const path = require('path');
@ -18,14 +19,17 @@ const getEnvConfig = () => {
const custom = parse(customSettings); const custom = parse(customSettings);
const merged = { ...defaults.frontend_dev, ...custom.frontend_dev }; const merged = { ...defaults.frontend_dev, ...custom.frontend_dev };
// Take all frontend keys from the ini file and prefix with `frontend_dev_`, // Take all frontend keys from the ini file and prefix with `frontend_dev_`,
// so they can be added to `process.env` elsewhere // so they can be added to `process.env` elsewhere
return Object.entries(merged).reduce((acc, [key, value]) => { /** @type {Record<string, unknown>} */
return { const env = {};
...acc,
[`frontend_dev_${key}`]: value, for (const [key, value] of Object.entries(merged)) {
}; env[`frontend_dev_${key}`] = value;
}, {}); }
return env;
}; };
module.exports = getEnvConfig; module.exports = getEnvConfig;