|
|
|
@ -12,12 +12,18 @@ const eslintPathsToIgnore = [ |
|
|
|
|
'public/app/plugins/panel/graph', // will be removed alongside angular
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// Avoid using functions that report the position of the issues, as this causes a lot of merge conflicts
|
|
|
|
|
export default { |
|
|
|
|
'better eslint': () => |
|
|
|
|
countEslintErrors() |
|
|
|
|
.include('**/*.{ts,tsx}') |
|
|
|
|
.exclude(new RegExp(eslintPathsToIgnore.join('|'))), |
|
|
|
|
'no undocumented stories': () => countUndocumentedStories().include('**/!(*.internal).story.tsx'), |
|
|
|
|
'no gf-form usage': () => |
|
|
|
|
regexp( |
|
|
|
|
/gf-form/gm, |
|
|
|
|
'gf-form usage has been deprecated. Use a component from @grafana/ui or custom CSS instead.' |
|
|
|
|
).include('**/*.{ts,tsx,html}'), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function countUndocumentedStories() { |
|
|
|
@ -38,6 +44,28 @@ function countUndocumentedStories() { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generic regexp pattern matcher, similar to @betterer/regexp. |
|
|
|
|
* The only difference is that the positions of the errors are not reported, as this may cause a lot of merge conflicts. |
|
|
|
|
*/ |
|
|
|
|
function regexp(pattern: RegExp, issueMessage: string) { |
|
|
|
|
return new BettererFileTest(async (filePaths, fileTestResult) => { |
|
|
|
|
await Promise.all( |
|
|
|
|
filePaths.map(async (filePath) => { |
|
|
|
|
const fileText = await fs.readFile(filePath, 'utf8'); |
|
|
|
|
const matches = fileText.match(pattern); |
|
|
|
|
if (matches) { |
|
|
|
|
// File contents doesn't matter, since we're not reporting the position
|
|
|
|
|
const file = fileTestResult.addFile(filePath, ''); |
|
|
|
|
matches.forEach(() => { |
|
|
|
|
file.addIssue(0, 0, issueMessage); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function countEslintErrors() { |
|
|
|
|
return new BettererFileTest(async (filePaths, fileTestResult, resolver) => { |
|
|
|
|
const { baseDirectory } = resolver; |
|
|
|
|