@@ -5,10 +5,47 @@ import coreLib from '@actions/core'
5
5
import github from '#src/workflows/github.ts'
6
6
import { getEnvInputs } from '#src/workflows/get-env-inputs.ts'
7
7
import { createReportIssue , linkReports } from '#src/workflows/issue-report.js'
8
+ import { reportingConfig } from '#src/content-linter/style/github-docs.js'
8
9
9
10
// GitHub issue body size limit is ~65k characters, so we'll use 60k as a safe limit
10
11
const MAX_ISSUE_BODY_SIZE = 60000
11
12
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
+
12
49
// [start-readme]
13
50
//
14
51
// This script runs once a week via a scheduled GitHub Action to lint
@@ -46,15 +83,26 @@ async function main() {
46
83
// or open an issue report, you might get cryptic error messages from Octokit.
47
84
getEnvInputs ( [ 'GITHUB_TOKEN' ] )
48
85
49
- core . info ( `Creating issue for errors and warnings ...` )
86
+ core . info ( `Creating issue for configured lint rules ...` )
50
87
51
88
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'
54
102
let filesIncluded = 0
55
103
let truncated = false
56
104
57
- for ( const [ file , flaws ] of Object . entries ( parsedResults ) ) {
105
+ for ( const [ file , flaws ] of Object . entries ( filteredResults ) ) {
58
106
const fileEntry = `File: \`${ file } \`:\n\`\`\`json\n${ JSON . stringify ( flaws , null , 2 ) } \n\`\`\`\n`
59
107
60
108
// Check if adding this file would exceed the size limit
@@ -77,7 +125,7 @@ async function main() {
77
125
const reportProps = {
78
126
core,
79
127
octokit,
80
- reportTitle : `Error(s) and warning(s) in content markdown file(s) ` ,
128
+ reportTitle : `Content linting issues requiring attention ` ,
81
129
reportBody,
82
130
reportRepository : REPORT_REPOSITORY ,
83
131
reportLabel : REPORT_LABEL ,
0 commit comments