@@ -5,10 +5,47 @@ import coreLib from '@actions/core'
55import github from '#src/workflows/github.ts'
66import { getEnvInputs } from '#src/workflows/get-env-inputs.ts'
77import { createReportIssue , linkReports } from '#src/workflows/issue-report.js'
8+ import { reportingConfig } from '#src/content-linter/style/github-docs.js'
89
910// GitHub issue body size limit is ~65k characters, so we'll use 60k as a safe limit
1011const MAX_ISSUE_BODY_SIZE = 60000
1112
13+ /**
14+ * Determines if a lint result should be included in the automated report
15+ * @param {Object } flaw - The lint result object
16+ * @param {string } flaw.severity - 'error' or 'warning'
17+ * @param {string[] } flaw.ruleNames - Array of rule names for this flaw
18+ * @returns {boolean } - True if this flaw should be included in the report
19+ */
20+ function shouldIncludeInReport ( flaw ) {
21+ if ( ! flaw . ruleNames || ! Array . isArray ( flaw . ruleNames ) ) {
22+ return false
23+ }
24+
25+ // Check if any rule name is in the exclude list
26+ const hasExcludedRule = flaw . ruleNames . some ( ( ruleName ) =>
27+ reportingConfig . excludeRules . includes ( ruleName ) ,
28+ )
29+ if ( hasExcludedRule ) {
30+ return false
31+ }
32+
33+ // Check if severity should be included
34+ if ( reportingConfig . includeSeverities . includes ( flaw . severity ) ) {
35+ return true
36+ }
37+
38+ // Check if any rule name is in the include list
39+ const hasIncludedRule = flaw . ruleNames . some ( ( ruleName ) =>
40+ reportingConfig . includeRules . includes ( ruleName ) ,
41+ )
42+ if ( hasIncludedRule ) {
43+ return true
44+ }
45+
46+ return false
47+ }
48+
1249// [start-readme]
1350//
1451// This script runs once a week via a scheduled GitHub Action to lint
@@ -46,15 +83,26 @@ async function main() {
4683 // or open an issue report, you might get cryptic error messages from Octokit.
4784 getEnvInputs ( [ 'GITHUB_TOKEN' ] )
4885
49- core . info ( `Creating issue for errors and warnings ...` )
86+ core . info ( `Creating issue for configured lint rules ...` )
5087
5188 const parsedResults = JSON . parse ( lintResults )
52- const totalFiles = Object . keys ( parsedResults ) . length
53- let reportBody = 'The following files have markdown lint warnings/errors:\n\n'
89+
90+ // Filter results based on reporting configuration
91+ const filteredResults = { }
92+ for ( const [ file , flaws ] of Object . entries ( parsedResults ) ) {
93+ const filteredFlaws = flaws . filter ( shouldIncludeInReport )
94+
95+ // Only include files that have remaining flaws after filtering
96+ if ( filteredFlaws . length > 0 ) {
97+ filteredResults [ file ] = filteredFlaws
98+ }
99+ }
100+ const totalFiles = Object . keys ( filteredResults ) . length
101+ let reportBody = 'The following files have markdown lint issues that require attention:\n\n'
54102 let filesIncluded = 0
55103 let truncated = false
56104
57- for ( const [ file , flaws ] of Object . entries ( parsedResults ) ) {
105+ for ( const [ file , flaws ] of Object . entries ( filteredResults ) ) {
58106 const fileEntry = `File: \`${ file } \`:\n\`\`\`json\n${ JSON . stringify ( flaws , null , 2 ) } \n\`\`\`\n`
59107
60108 // Check if adding this file would exceed the size limit
@@ -77,7 +125,7 @@ async function main() {
77125 const reportProps = {
78126 core,
79127 octokit,
80- reportTitle : `Error(s) and warning(s) in content markdown file(s) ` ,
128+ reportTitle : `Content linting issues requiring attention ` ,
81129 reportBody,
82130 reportRepository : REPORT_REPOSITORY ,
83131 reportLabel : REPORT_LABEL ,
0 commit comments