Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Console.log(workerReference, chalk.yellow('transpiling JS/TS'));
Promise.all(
fileNames.map((fileName) => transpileToES5(fileName, applicationName, projectRoot))
)
.then((result) => parentPort.postMessage(result))
.catch((error) => {
Console.log(workerReference, chalk.red('ERROR OCCURED DURING TRANSPILATION:'));
console.log(error);
parentPort.postMessage({ error: normalizeError(error) });
});
} else if (action === 'LINT_JS') {
Console.log(workerReference, chalk.yellow('linting JS/TS'));
global.jsLinter = global.jsLinter || new eslint.CLIEngine();
try {
const timer = countTime();
lintJavaScript(fileNames, global.jsLinter);
Console.log(
workerReference,
chalk.green(`lint passes successfully in ${formatTimePassed(timer.stop())}`)
);
parentPort.postMessage(true);
} catch (error) {
console.log('ERROR IS', error);
parentPort.postMessage({ error: normalizeError(error) });
baseConfig: (() => {
const eslintCli = new eslint.CLIEngine();
let eslintConfig;
try {
eslintConfig = eslintCli.getConfigForFile(paths.appIndexJs);
} catch (e) {
// A config couldn't be found.
}
// We allow overriding the config only if the env variable is set
if (process.env.EXTEND_ESLINT === 'true' && eslintConfig) {
return eslintConfig;
} else {
return {
extends: [require.resolve('eslint-config-react-app')],
};
}
})(),
it('should load properly base config', () => {
const cli = new eslint.CLIEngine({
useEslintrc: false,
baseConfig: {
extends: '@salesforce/eslint-config-lwc/base',
},
});
const report = cli.executeOnText(`
import { api } from 'lwc';
class Foo {
@api({ param: true })
foo;
}
`);
const { messages } = report.results[0];
assert.equal(messages.length, 1);
function execute(file, baseConfig) {
if (!baseConfig) baseConfig = {}
const cli = new CLIEngine({
extensions: ["html"],
baseConfig: {
settings: baseConfig.settings,
rules: Object.assign(
{
"no-console": 2,
},
baseConfig.rules
),
globals: baseConfig.globals,
env: baseConfig.env,
parserOptions: baseConfig.parserOptions,
},
ignore: false,
useEslintrc: false,
fix: baseConfig.fix,
})
html('a').each((i, elem) => {
if (elem.attribs.href) {
reportHtml(file, 'a', 'href', elem.attribs.href)
}
})
html('script').each((i, elem) => {
if (elem.attribs.src) {
reportHtml(file, 'script', 'src', elem.attribs.src)
}
})
} catch (e) {
console.error(e)
}
})
var jsResults = new CLIEngine().executeOnFiles(['./'])
jsResults.results = jsResults.results.filter(function(result) {
delete result.source
return result.errorCount
})
if (jsResults.errorCount || htmlResults.errorCount) {
throw new Error(
'Non-relative paths found' +
'\n' +
JSON.stringify(jsResults, null, 2) +
'\n' +
JSON.stringify(htmlResults, null, 2)
)
}
}
if (!Fs.existsSync('.eslintrc.js') &&
!Fs.existsSync('.eslintrc.yaml') &&
!Fs.existsSync('.eslintrc.yml') &&
!Fs.existsSync('.eslintrc.json') &&
!Fs.existsSync('.eslintrc')) {
configuration.configFile = Path.join(__dirname, '.eslintrc.js');
}
if (options) {
Hoek.merge(configuration, options, true, false);
}
let results;
try {
const engine = new Eslint.CLIEngine(configuration);
results = engine.executeOnFiles(['.']);
}
catch (ex) {
results = {
results: [{ messages: [ex] }]
};
}
return results.results.map((result) => {
const transformed = {
filename: result.filePath
};
if (result.hasOwnProperty('output')) {
);
if (!workspacePath) {
const engine = new CLIEngine(defaultOpts.eslint);
return engine.executeOnText(str, filePath);
}
const workspaceOpts = pkgConf.sync('marlint', { cwd: workspacePath });
const mergedOpts = {
eslint: {
...defaultOpts.eslint,
rules: { ...defaultOpts.eslint.rules, ...workspaceOpts.rules },
globals: defaultOpts.eslint.globals.concat(workspaceOpts.globals || []),
},
};
const engine = new CLIEngine(mergedOpts.eslint);
return engine.executeOnText(str, filePath);
}
const engine = new CLIEngine(defaultOpts.eslint);
return engine.executeOnText(str, filePath);
};
function processFiles(glob){
var cli = new ESLint.CLIEngine();
var report = cli.executeOnFiles(cli.resolveFileGlobPatterns([glob]));
return report;
}
* DON'T EDIT THIS FILE WHICH WAS GENERATED BY './scripts/generate-configs.js'.
*/
"use strict"
module.exports = {
${fs
.readdirSync(path.resolve(__dirname, "../lib/configs"))
.map(fileName => path.basename(fileName, ".js"))
.filter(id => !id.startsWith("_"))
.map(id => ` "${id}": require("./configs/${id}"),`)
.join("\n")}
}
`
)
const linter = new CLIEngine({ fix: true })
const result = linter.executeOnFiles([targetFile])
CLIEngine.outputFixes(result)