|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | /** @typedef {import('eslint').ESLint} ESLint */
|
|---|
| 4 |
|
|---|
| 5 | /** @typedef {import('eslint').ESLint.Options} ESLintOptions */
|
|---|
| 6 | Object.assign(module.exports, {
|
|---|
| 7 | lintFiles,
|
|---|
| 8 | setup
|
|---|
| 9 | });
|
|---|
| 10 | /** @type {{ new (arg0: import("eslint").ESLint.Options): import("eslint").ESLint; outputFixes: (arg0: import("eslint").ESLint.LintResult[]) => any; }} */
|
|---|
| 11 |
|
|---|
| 12 | let ESLint;
|
|---|
| 13 | /** @type {ESLint} */
|
|---|
| 14 |
|
|---|
| 15 | let eslint;
|
|---|
| 16 | /** @type {boolean} */
|
|---|
| 17 |
|
|---|
| 18 | let fix;
|
|---|
| 19 | /**
|
|---|
| 20 | * @typedef {object} setupOptions
|
|---|
| 21 | * @property {string=} eslintPath - import path of eslint
|
|---|
| 22 | * @property {ESLintOptions=} eslintOptions - linter options
|
|---|
| 23 | *
|
|---|
| 24 | * @param {setupOptions} arg0 - setup worker
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | function setup({
|
|---|
| 28 | eslintPath,
|
|---|
| 29 | eslintOptions = {}
|
|---|
| 30 | }) {
|
|---|
| 31 | fix = !!(eslintOptions && eslintOptions.fix);
|
|---|
| 32 | ({
|
|---|
| 33 | ESLint
|
|---|
| 34 | } = require(eslintPath || 'eslint'));
|
|---|
| 35 | eslint = new ESLint(eslintOptions);
|
|---|
| 36 | }
|
|---|
| 37 | /**
|
|---|
| 38 | * @param {string | string[]} files
|
|---|
| 39 | */
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | async function lintFiles(files) {
|
|---|
| 43 | const result = await eslint.lintFiles(files); // if enabled, use eslint autofixing where possible
|
|---|
| 44 |
|
|---|
| 45 | if (fix) {
|
|---|
| 46 | await ESLint.outputFixes(result);
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | return result;
|
|---|
| 50 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.