katoikia-app/web-ui/web-react/node_modules/eslint-loader/dist/cacheLoader.js

55 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-07-06 04:15:11 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = cacheLoader;
var _loaderFsCache = _interopRequireDefault(require("loader-fs-cache"));
var _package = require("../package.json");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const cache = (0, _loaderFsCache.default)('eslint-loader');
function cacheLoader(linter, content, map) {
const {
loaderContext,
options,
CLIEngine
} = linter;
const callback = loaderContext.async();
const cacheIdentifier = JSON.stringify({
'eslint-loader': _package.version,
eslint: CLIEngine.version
});
cache({
directory: options.cache,
identifier: cacheIdentifier,
options,
source: content,
transform() {
return linter.lint(content);
}
}, (err, res) => {
// istanbul ignore next
if (err) {
return callback(err);
}
let error = err;
try {
linter.printOutput({ ...res,
src: content
});
} catch (e) {
error = e;
}
return callback(error, content, map);
});
}