The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/.betterer.ts

40 lines
1.4 KiB

import { regexp } from '@betterer/regexp';
import { eslint } from '@betterer/eslint';
import { BettererFileTest } from '@betterer/betterer';
export default {
'no enzyme tests': () => regexp(/from 'enzyme'/g).include('**/*.test.*'),
'better eslint': () =>
eslint({
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'never',
},
],
}).include('**/*.{ts,tsx}'),
'no undocumented stories': () => countUndocumentedStories().include('**/*.{story.tsx,mdx}'),
};
function countUndocumentedStories() {
return new BettererFileTest(async (filePaths, fileTestResult) => {
const storyFilePaths = filePaths.filter((filePath) => filePath.endsWith('story.tsx'));
const mdxFilePaths = filePaths.filter((filePath) => filePath.endsWith('mdx'));
storyFilePaths.forEach((filePath) => {
if (!mdxFilePaths.includes(filePath.replace(/\.story.tsx$/, '.mdx'))) {
// In this case the file contents don't matter:
const file = fileTestResult.addFile(filePath, '');
// Add the issue to the first character of the file:
file.addIssue(
0,
0,
`No undocumented stories are allowed, please add a ${filePath.replace(
/^(.*\/)(\w+)\.story\.tsx$/,
'$2.mdx'
)} with some documentation.`
);
}
});
});
}