MCPcopy
hub / github.com/processing/p5.js / eslintFiles

Function eslintFiles

utils/sample-linter.mjs:166–218  ·  view source on GitHub ↗
(opts, filesSrc)

Source from the content-addressed store, hash-verified

164};
165
166async function eslintFiles(opts, filesSrc) {
167 opts = opts || {
168 outputFile: false,
169 quiet: false,
170 maxWarnings: -1,
171 envs: ['eslint-samples/p5', 'amd'],
172 format: 'unix'
173 };
174
175 const eslint = new ESLint({
176 plugins: {
177 'eslint-samples': plugin
178 },
179 overrideConfig: {
180 'plugins': ['eslint-samples']
181 },
182 fix: opts.fix
183 });
184
185 if (filesSrc.length === 0) {
186 console.warn('Could not find any files to validate');
187 return true;
188 }
189
190 const formatter = await eslint.loadFormatter(opts.format);
191 if (!formatter) {
192 console.warn(`Could not find formatter ${opts.format}`);
193 return false;
194 }
195
196 let results = await eslint.lintFiles(filesSrc);
197 const report = results.reduce((acc, result) => {
198 acc.errorCount += result.errorCount;
199 acc.warningCount += result.warningCount;
200 acc.fixableErrorCount += result.fixableErrorCount;
201 acc.fixableWarningCount += result.fixableWarningCount;
202 return acc;
203 }, {
204 errorCount: 0,
205 warningCount: 0,
206 fixableErrorCount: 0,
207 fixableWarningCount: 0
208 });
209
210 if (opts.quiet) {
211 results = ESLint.getErrorResults(results);
212 }
213
214 return {
215 report,
216 output: formatter.format(results)
217 };
218}
219
220function splitLines(text) {
221 const lines = [];

Callers 1

sample-linter.mjsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected