2222 See https://github.com/super-linter/super-linter.
2323 type : string
2424 required : false
25+ linter-toolchain :
26+ description : |
27+ Lint toolchain to use for Super-Linter frontend validators.
28+ Supported values: biome, eslint-prettier.
29+ type : string
30+ required : false
31+ default : biome
2532 codeql-languages :
2633 description : |
2734 JSON array of languages to analyze with CodeQL.
@@ -75,14 +82,92 @@ jobs:
7582 fetch-depth : " ${{ inputs.lint-all && 1 || 0 }}"
7683 persist-credentials : false
7784
78- - if : ${{ inputs.linter-env }}
85+ - uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
7986 env :
8087 LINTER_ENV : ${{ inputs.linter-env }}
81- run : |
82- echo "$LINTER_ENV" | while IFS= read -r line; do
83- if [ -z "$line" ]; then continue; fi
84- echo "$line" >> "$GITHUB_ENV"
85- done
88+ LINTER_TOOLCHAIN : ${{ inputs.linter-toolchain }}
89+ with :
90+ script : |
91+ const toolchainVariables = {
92+ biome: {
93+ VALIDATE_CSS: "false",
94+ VALIDATE_CSS_PRETTIER: "false",
95+ VALIDATE_GRAPHQL_PRETTIER: "false",
96+ VALIDATE_HTML_PRETTIER: "false",
97+ VALIDATE_JAVASCRIPT_ES: "false",
98+ VALIDATE_JAVASCRIPT_PRETTIER: "false",
99+ VALIDATE_JSON: "false",
100+ VALIDATE_JSON_PRETTIER: "false",
101+ VALIDATE_JSONC: "false",
102+ VALIDATE_JSONC_PRETTIER: "false",
103+ VALIDATE_JSX: "false",
104+ VALIDATE_JSX_PRETTIER: "false",
105+ VALIDATE_TYPESCRIPT_ES: "false",
106+ VALIDATE_TYPESCRIPT_PRETTIER: "false",
107+ VALIDATE_TSX: "false",
108+ VALIDATE_VUE: "false",
109+ VALIDATE_VUE_PRETTIER: "false",
110+ },
111+ "eslint-prettier": {
112+ VALIDATE_BIOME_FORMAT: "false",
113+ VALIDATE_BIOME_LINT: "false",
114+ },
115+ };
116+
117+ function parseEnvironmentLines(serializedEnvironment) {
118+ const environment = new Map();
119+
120+ for (const rawLine of serializedEnvironment.split("\n")) {
121+ const line = rawLine.trim();
122+ if (line === "") {
123+ continue;
124+ }
125+
126+ const separatorIndex = line.indexOf("=");
127+ if (separatorIndex <= 0) {
128+ throw new Error(`Invalid linter-env entry: ${rawLine}`);
129+ }
130+
131+ const key = line.slice(0, separatorIndex).trim();
132+ const value = line.slice(separatorIndex + 1);
133+ if (key === "") {
134+ throw new Error(`Invalid linter-env entry: ${rawLine}`);
135+ }
136+
137+ environment.set(key, value);
138+ }
139+
140+ return environment;
141+ }
142+
143+ function getToolchainEnvironment(toolchain) {
144+ const environment = toolchainVariables[toolchain];
145+ if (!environment) {
146+ throw new Error(`Unsupported lint toolchain: ${toolchain}`);
147+ }
148+
149+ return environment;
150+ }
151+
152+ function mergeEnvironment(customEnvironment, defaultEnvironment) {
153+ const mergedEnvironment = new Map(customEnvironment);
154+
155+ for (const [key, value] of Object.entries(defaultEnvironment)) {
156+ if (!mergedEnvironment.has(key)) {
157+ mergedEnvironment.set(key, value);
158+ }
159+ }
160+
161+ return mergedEnvironment;
162+ }
163+
164+ const customEnvironment = parseEnvironmentLines(process.env.LINTER_ENV ?? "");
165+ const defaultEnvironment = getToolchainEnvironment(process.env.LINTER_TOOLCHAIN);
166+ const mergedEnvironment = mergeEnvironment(customEnvironment, defaultEnvironment);
167+
168+ for (const [key, value] of mergedEnvironment) {
169+ core.exportVariable(key, value);
170+ }
86171
87172 # FIXME: superlinter should auto install required dependencies. See https://github.com/super-linter/super-linter/issues/6089.
88173 - id : has-prettier-plugins
@@ -104,12 +189,12 @@ jobs:
104189 with :
105190 working-directory : ${{ steps.has-prettier-plugins.outputs.package-json-dir }}
106191
107- - uses : super-linter/super-linter/slim@5119dcd8011e92182ce8219d9e9efc82f16fddb6 # v8.0 .0
192+ - uses : super-linter/super-linter/slim@9e863354e3ff62e0727d37183162c4a88873df41 # v8.6 .0
108193 env :
109194 VALIDATE_ALL_CODEBASE : ${{ inputs.lint-all }}
110195 LOG_LEVEL : WARN
111196 DEFAULT_BRANCH : ${{ github.event.repository.default_branch }}
112- GITHUB_TOKEN : ${{ secrets.github-token || github.token }}
197+ GITHUB_TOKEN : ${{ secrets.github-token || github.token }} # zizmor: ignore[secrets-outside-env] reusable workflow token override is intentional
113198 IGNORE_GITIGNORED_FILES : " true"
114199
115200 codeql :
0 commit comments