source: frontend/node_modules/eslint-webpack-plugin/dist/options.js

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: 2.4 KB
Line 
1"use strict";
2
3const {
4 validate
5} = require('schema-utils');
6
7const schema = require('./options.json');
8/** @typedef {import("eslint").ESLint.Options} ESLintOptions */
9
10/** @typedef {import('eslint').ESLint.LintResult} LintResult */
11
12/** @typedef {import('eslint').ESLint.LintResultData} LintResultData */
13
14/**
15 * @callback FormatterFunction
16 * @param {LintResult[]} results
17 * @param {LintResultData=} data
18 * @returns {string}
19 */
20
21/**
22 * @typedef {Object} OutputReport
23 * @property {string=} filePath
24 * @property {string|FormatterFunction=} formatter
25 */
26
27/**
28 * @typedef {Object} PluginOptions
29 * @property {string=} context
30 * @property {boolean=} emitError
31 * @property {boolean=} emitWarning
32 * @property {string=} eslintPath
33 * @property {string|string[]=} exclude
34 * @property {string|string[]=} extensions
35 * @property {boolean=} failOnError
36 * @property {boolean=} failOnWarning
37 * @property {string|string[]=} files
38 * @property {boolean=} fix
39 * @property {string|FormatterFunction=} formatter
40 * @property {boolean=} lintDirtyModulesOnly
41 * @property {boolean=} quiet
42 * @property {OutputReport=} outputReport
43 * @property {number|boolean=} threads
44 * @property {RegExp|RegExp[]=} resourceQueryExclude
45 */
46
47/** @typedef {PluginOptions & ESLintOptions} Options */
48
49/**
50 * @param {Options} pluginOptions
51 * @returns {PluginOptions}
52 */
53
54
55function getOptions(pluginOptions) {
56 const options = {
57 extensions: 'js',
58 emitError: true,
59 emitWarning: true,
60 failOnError: true,
61 resourceQueryExclude: [],
62 ...pluginOptions,
63 ...(pluginOptions.quiet ? {
64 emitError: true,
65 emitWarning: false
66 } : {})
67 }; // @ts-ignore
68
69 validate(schema, options, {
70 name: 'ESLint Webpack Plugin',
71 baseDataPath: 'options'
72 });
73 return options;
74}
75/**
76 * @param {Options} loaderOptions
77 * @returns {ESLintOptions}
78 */
79
80
81function getESLintOptions(loaderOptions) {
82 const eslintOptions = { ...loaderOptions
83 }; // Keep the fix option because it is common to both the loader and ESLint.
84
85 const {
86 fix,
87 extensions,
88 ...eslintOnlyOptions
89 } = schema.properties; // No need to guard the for-in because schema.properties has hardcoded keys.
90 // eslint-disable-next-line guard-for-in
91
92 for (const option in eslintOnlyOptions) {
93 // @ts-ignore
94 delete eslintOptions[option];
95 }
96
97 return eslintOptions;
98}
99
100module.exports = {
101 getOptions,
102 getESLintOptions
103};
Note: See TracBrowser for help on using the repository browser.