eslint-webpack-plugin
Advanced tools
Comparing version 2.6.0 to 2.7.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
class ESLintError extends Error { | ||
@@ -20,3 +15,2 @@ /** | ||
var _default = ESLintError; | ||
exports.default = _default; | ||
module.exports = ESLintError; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = getESLint; | ||
exports.loadESLint = loadESLint; | ||
exports.loadESLintThreaded = loadESLintThreaded; | ||
const { | ||
cpus | ||
} = require('os'); | ||
var _os = require("os"); | ||
const { | ||
Worker: JestWorker | ||
} = require('jest-worker'); | ||
var _jestWorker = require("jest-worker"); | ||
const { | ||
getESLintOptions | ||
} = require('./options'); | ||
var _options = require("./options"); | ||
const { | ||
jsonStringifyReplacerSortKeys | ||
} = require('./utils'); | ||
/** @type {{[key: string]: any}} */ | ||
var _utils = require("./utils"); | ||
/** @type {{[key: string]: any}} */ | ||
const cache = {}; | ||
@@ -49,3 +51,3 @@ /** @typedef {import('eslint').ESLint} ESLint */ | ||
const eslint = new ESLint((0, _options.getESLintOptions)(options)); | ||
const eslint = new ESLint(getESLintOptions(options)); | ||
return { | ||
@@ -89,12 +91,9 @@ threads: 1, | ||
eslintPath, | ||
eslintOptions: (0, _options.getESLintOptions)(options) | ||
eslintOptions: getESLintOptions(options) | ||
}] | ||
}; | ||
const local = loadESLint(options); | ||
let worker = | ||
/** @type {Worker?} */ | ||
// prettier-ignore | ||
let worker = | ||
/** @type {Worker} */ | ||
new _jestWorker.Worker(source, workerOptions); | ||
new JestWorker(source, workerOptions); | ||
/** @type {Linter} */ | ||
@@ -131,3 +130,3 @@ | ||
}) { | ||
const max = typeof threads !== 'number' ? threads ? (0, _os.cpus)().length - 1 : 1 : | ||
const max = typeof threads !== 'number' ? threads ? cpus().length - 1 : 1 : | ||
/* istanbul ignore next */ | ||
@@ -157,3 +156,9 @@ threads; | ||
options | ||
}, _utils.jsonStringifyReplacerSortKeys); | ||
} | ||
}, jsonStringifyReplacerSortKeys); | ||
} | ||
module.exports = { | ||
loadESLint, | ||
loadESLintThreaded, | ||
getESLint | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
const { | ||
isAbsolute, | ||
join | ||
} = require('path'); // @ts-ignore | ||
var _path = require("path"); | ||
var _arrify = _interopRequireDefault(require("arrify")); | ||
const arrify = require('arrify'); | ||
var _micromatch = require("micromatch"); | ||
const { | ||
isMatch | ||
} = require('micromatch'); | ||
var _options = require("./options"); | ||
const { | ||
getOptions | ||
} = require('./options'); | ||
var _linter = _interopRequireDefault(require("./linter")); | ||
const linter = require('./linter'); | ||
var _utils = require("./utils"); | ||
const { | ||
parseFiles, | ||
parseFoldersToGlobs | ||
} = require('./utils'); | ||
/** @typedef {import('webpack').Compiler} Compiler */ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** @typedef {import('./options').Options} Options */ | ||
// @ts-ignore | ||
/** @typedef {import('webpack').Compiler} Compiler */ | ||
/** @typedef {import('./options').Options} Options */ | ||
const ESLINT_PLUGIN = 'ESLintWebpackPlugin'; | ||
@@ -36,3 +39,3 @@ let counter = 0; | ||
this.key = ESLINT_PLUGIN; | ||
this.options = (0, _options.getOptions)(options); | ||
this.options = getOptions(options); | ||
this.run = this.run.bind(this); | ||
@@ -51,8 +54,8 @@ } | ||
const options = { ...this.options, | ||
exclude: (0, _utils.parseFiles)(this.options.exclude || [], this.getContext(compiler)), | ||
extensions: (0, _arrify.default)(this.options.extensions), | ||
files: (0, _utils.parseFiles)(this.options.files || '', this.getContext(compiler)) | ||
exclude: parseFiles(this.options.exclude || [], this.getContext(compiler)), | ||
extensions: arrify(this.options.extensions), | ||
files: parseFiles(this.options.files || '', this.getContext(compiler)) | ||
}; | ||
const wanted = (0, _utils.parseFoldersToGlobs)(options.files, options.extensions); | ||
const exclude = (0, _utils.parseFoldersToGlobs)(this.options.exclude ? options.exclude : '**/node_modules/**', []); // If `lintDirtyModulesOnly` is disabled, | ||
const wanted = parseFoldersToGlobs(options.files, options.extensions); | ||
const exclude = parseFoldersToGlobs(this.options.exclude ? options.exclude : '**/node_modules/**', []); // If `lintDirtyModulesOnly` is disabled, | ||
// execute the linter on the build | ||
@@ -106,3 +109,3 @@ | ||
threads | ||
} = (0, _linter.default)(this.key, options, compilation)); | ||
} = linter(this.key, options, compilation)); | ||
} catch (e) { | ||
@@ -124,5 +127,5 @@ compilation.errors.push(e); | ||
if (file && !files.includes(file) && (0, _micromatch.isMatch)(file, wanted, { | ||
if (file && !files.includes(file) && isMatch(file, wanted, { | ||
dot: true | ||
}) && !(0, _micromatch.isMatch)(file, exclude, { | ||
}) && !isMatch(file, exclude, { | ||
dot: true | ||
@@ -188,4 +191,4 @@ })) { | ||
if (!(0, _path.isAbsolute)(this.options.context)) { | ||
return (0, _path.join)(String(compiler.options.context), this.options.context); | ||
if (!isAbsolute(this.options.context)) { | ||
return join(String(compiler.options.context), this.options.context); | ||
} | ||
@@ -198,3 +201,2 @@ | ||
var _default = ESLintWebpackPlugin; | ||
exports.default = _default; | ||
module.exports = ESLintWebpackPlugin; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = linter; | ||
const { | ||
dirname, | ||
isAbsolute, | ||
join | ||
} = require('path'); | ||
var _path = require("path"); | ||
const ESLintError = require('./ESLintError'); | ||
var _ESLintError = _interopRequireDefault(require("./ESLintError")); | ||
var _getESLint = _interopRequireDefault(require("./getESLint")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const { | ||
getESLint | ||
} = require('./getESLint'); | ||
/** @typedef {import('eslint').ESLint} ESLint */ | ||
@@ -41,2 +39,4 @@ | ||
/** @type {WeakMap<Compiler, LintResultMap>} */ | ||
const resultStorage = new WeakMap(); | ||
@@ -73,5 +73,5 @@ /** | ||
threads | ||
} = (0, _getESLint.default)(key, options)); | ||
} = getESLint(key, options)); | ||
} catch (e) { | ||
throw new _ESLintError.default(e.message); | ||
throw new ESLintError(e.message); | ||
} | ||
@@ -150,3 +150,3 @@ | ||
mkdir((0, _path.dirname)(name), { | ||
mkdir(dirname(name), { | ||
recursive: true | ||
@@ -171,4 +171,4 @@ }, err => { | ||
if (!(0, _path.isAbsolute)(filePath)) { | ||
filePath = (0, _path.join)(compiler.outputPath, filePath); | ||
if (!isAbsolute(filePath)) { | ||
filePath = join(compiler.outputPath, filePath); | ||
} | ||
@@ -192,7 +192,7 @@ | ||
if (results.warnings.length > 0) { | ||
warnings = new _ESLintError.default(formatter.format(results.warnings)); | ||
warnings = new ESLintError(formatter.format(results.warnings)); | ||
} | ||
if (results.errors.length > 0) { | ||
errors = new _ESLintError.default(formatter.format(results.errors)); | ||
errors = new ESLintError(formatter.format(results.errors)); | ||
} | ||
@@ -344,2 +344,4 @@ | ||
return Array.isArray(x) ? x : [x]; | ||
} | ||
} | ||
module.exports = linter; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getESLintOptions = getESLintOptions; | ||
exports.getOptions = getOptions; | ||
const { | ||
validate | ||
} = require('schema-utils'); // @ts-ignore | ||
var _schemaUtils = require("schema-utils"); | ||
var _options = _interopRequireDefault(require("./options.json")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// @ts-ignore | ||
const schema = require('./options.json'); | ||
/** @typedef {import("eslint").ESLint.Options} ESLintOptions */ | ||
@@ -61,2 +53,4 @@ | ||
*/ | ||
function getOptions(pluginOptions) { | ||
@@ -75,3 +69,3 @@ const options = { | ||
(0, _schemaUtils.validate)(_options.default, options, { | ||
validate(schema, options, { | ||
name: 'ESLint Webpack Plugin', | ||
@@ -96,3 +90,3 @@ baseDataPath: 'options' | ||
...eslintOnlyOptions | ||
} = _options.default.properties; // No need to guard the for-in because schema.properties has hardcoded keys. | ||
} = schema.properties; // No need to guard the for-in because schema.properties has hardcoded keys. | ||
// eslint-disable-next-line guard-for-in | ||
@@ -106,2 +100,7 @@ | ||
return eslintOptions; | ||
} | ||
} | ||
module.exports = { | ||
getOptions, | ||
getESLintOptions | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.jsonStringifyReplacerSortKeys = void 0; | ||
exports.parseFiles = parseFiles; | ||
exports.parseFoldersToGlobs = parseFoldersToGlobs; | ||
const { | ||
resolve | ||
} = require('path'); | ||
var _path = require("path"); | ||
const { | ||
statSync | ||
} = require('fs'); | ||
var _fs = require("fs"); | ||
const normalizePath = require('normalize-path'); | ||
var _normalizePath = _interopRequireDefault(require("normalize-path")); | ||
var _arrify = _interopRequireDefault(require("arrify")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// @ts-ignore | ||
// @ts-ignore | ||
const arrify = require('arrify'); | ||
/** | ||
@@ -28,6 +19,8 @@ * @param {string|string[]} files | ||
*/ | ||
function parseFiles(files, context) { | ||
return (0, _arrify.default)(files).map(( | ||
return arrify(files).map(( | ||
/** @type {string} */ | ||
file) => (0, _normalizePath.default)((0, _path.resolve)(context, file))); | ||
file) => normalizePath(resolve(context, file))); | ||
} | ||
@@ -42,3 +35,3 @@ /** | ||
function parseFoldersToGlobs(patterns, extensions = []) { | ||
const extensionsList = (0, _arrify.default)(extensions); | ||
const extensionsList = arrify(extensions); | ||
const [prefix, postfix] = extensionsList.length > 1 ? ['{', '}'] : ['', '']; | ||
@@ -48,3 +41,3 @@ const extensionsGlob = extensionsList.map(( | ||
extension) => extension.replace(/^\./u, '')).join(','); | ||
return (0, _arrify.default)(patterns).map(( | ||
return arrify(patterns).map(( | ||
/** @type {string} */ | ||
@@ -54,3 +47,3 @@ pattern) => { | ||
// The patterns are absolute because they are prepended with the context. | ||
const stats = (0, _fs.statSync)(pattern); | ||
const stats = statSync(pattern); | ||
/* istanbul ignore else */ | ||
@@ -88,2 +81,6 @@ | ||
exports.jsonStringifyReplacerSortKeys = jsonStringifyReplacerSortKeys; | ||
module.exports = { | ||
parseFiles, | ||
parseFoldersToGlobs, | ||
jsonStringifyReplacerSortKeys | ||
}; |
{ | ||
"name": "eslint-webpack-plugin", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"description": "A ESLint plugin for webpack", | ||
@@ -14,4 +14,4 @@ "license": "MIT", | ||
}, | ||
"main": "dist/cjs.js", | ||
"types": "declarations/index.d.ts", | ||
"main": "dist/index.js", | ||
"types": "types/index.d.ts", | ||
"engines": { | ||
@@ -22,5 +22,5 @@ "node": ">= 10.13.0" | ||
"start": "npm run build -- -w", | ||
"clean": "del-cli dist declarations", | ||
"clean": "del-cli dist types", | ||
"prebuild": "npm run clean", | ||
"build:types": "tsc --declaration --emitDeclarationOnly --outDir declarations && prettier \"declarations/**/*.ts\" --write", | ||
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write", | ||
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files", | ||
@@ -44,3 +44,3 @@ "build": "npm-run-all -p \"build:**\"", | ||
"dist", | ||
"declarations" | ||
"types" | ||
], | ||
@@ -52,6 +52,6 @@ "peerDependencies": { | ||
"dependencies": { | ||
"@types/eslint": "^7.28.2", | ||
"@types/eslint": "^7.29.0", | ||
"arrify": "^2.0.1", | ||
"jest-worker": "^27.3.1", | ||
"micromatch": "^4.0.4", | ||
"jest-worker": "^27.5.1", | ||
"micromatch": "^4.0.5", | ||
"normalize-path": "^3.0.0", | ||
@@ -61,5 +61,5 @@ "schema-utils": "^3.1.1" | ||
"devDependencies": { | ||
"@babel/cli": "^7.16.0", | ||
"@babel/core": "^7.16.0", | ||
"@babel/preset-env": "^7.16.0", | ||
"@babel/cli": "^7.17.10", | ||
"@babel/core": "^7.17.10", | ||
"@babel/preset-env": "^7.17.10", | ||
"@commitlint/cli": "^12.1.4", | ||
@@ -73,3 +73,3 @@ "@commitlint/config-conventional": "^12.1.4", | ||
"babel-eslint": "^10.1.0", | ||
"babel-jest": "^27.3.1", | ||
"babel-jest": "^27.5.1", | ||
"chokidar": "^3.5.2", | ||
@@ -79,14 +79,14 @@ "cross-env": "^7.0.3", | ||
"del-cli": "^3.0.1", | ||
"eslint": "^8.2.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.25.3", | ||
"eslint": "^8.14.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"fs-extra": "^9.1.0", | ||
"husky": "^6.0.0", | ||
"jest": "^27.3.1", | ||
"jest": "^27.5.1", | ||
"lint-staged": "^10.5.4", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.4.1", | ||
"prettier": "^2.6.2", | ||
"standard-version": "^9.3.2", | ||
"typescript": "^4.4.4", | ||
"webpack": "^5.64.0" | ||
"typescript": "^4.6.4", | ||
"webpack": "^5.72.0" | ||
}, | ||
@@ -93,0 +93,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1083
41539
18
Updated@types/eslint@^7.29.0
Updatedjest-worker@^27.5.1
Updatedmicromatch@^4.0.5