Browse Source

Removed custom tslint plugin.

pull/342/head
Sebastian 7 years ago
parent
commit
45634e4da8
  1. 2
      Dockerfile
  2. 2
      Dockerfile.build
  3. 41
      src/Squidex/app-config/tslint/linter.js
  4. 157
      src/Squidex/app-config/tslint/plugin.js
  5. 2
      src/Squidex/app-config/webpack.run.dev.js
  6. 2
      src/Squidex/app-config/webpack.run.prod.js
  7. 1013
      src/Squidex/package-lock.json
  8. 20
      src/Squidex/package.json

2
Dockerfile

@ -10,8 +10,6 @@ RUN cd /tmp && npm install
COPY . . COPY . .
WORKDIR /
# Build Frontend # Build Frontend
RUN cp -a /tmp/node_modules /src/Squidex/ \ RUN cp -a /tmp/node_modules /src/Squidex/ \
&& cd /src/Squidex \ && cd /src/Squidex \

2
Dockerfile.build

@ -8,8 +8,6 @@ RUN cd /tmp \
COPY . . COPY . .
WORKDIR /
# Build Frontend # Build Frontend
RUN cp -a /tmp/node_modules /src/Squidex/ \ RUN cp -a /tmp/node_modules /src/Squidex/ \
&& cd /src/Squidex \ && cd /src/Squidex \

41
src/Squidex/app-config/tslint/linter.js

@ -1,41 +0,0 @@
const { Runner, run } = require('tslint/lib/runner');
const options = JSON.parse(process.argv[2]) || {};
function logToParent(message) {
process.stdout.write(message);
}
function runLinter(runnerOptions, write) {
const logTsLint = message => {
write('tslint:' + message)
};
if (run) {
const logger = { log: logTsLint, error: logTsLint };
return run(runnerOptions, logger);
} else if (Runner) {
return new Promise(resolve => {
new Runner(runnerOptions, { write: logTsLint }).run(resolve);
});
} else {
write('tsinfo:Unable to launch tslint. No suitable runner found.');
}
}
logToParent('tsinfo:Linting started in separate process...');
const runnerOptions = Object.assign({
exclude: [],
format: 'json'
}, options);
runLinter(runnerOptions, logToParent)
.then(() => {
logToParent('tsinfo:Linting complete.');
process.exit();
}).catch(error => {
logToParent(`tserror:Error starting linter: ${error}\n${error.stack}`);
});

157
src/Squidex/app-config/tslint/plugin.js

@ -1,157 +0,0 @@
const path = require('path');
const chalk = require('chalk');
const { fork } = require('child_process');
function apply(options, compiler) {
let linterProcess;
let linterPromise;
let linterIteration = 0;
function compileHook() {
if (linterProcess && linterProcess.kill) {
// Exits any outstanding child process if one exists
linterProcess.kill();
}
let { files = [] } = options;
if (!files.length) {
process.stdout.write(chalk.yellow.bold('\n[tslint-plugin] No `files` option specified.\n'));
return;
}
options.files = Array.isArray(files) ? files : [files];
// Spawn a child process to run the linter
linterProcess = fork(path.resolve(__dirname, 'linter.js'), [JSON.stringify(options)], {
silent: true
});
// Use the iteration to cancel previous promises.
linterIteration++;
linterPromise = new Promise(resolve => {
const linterOutBuffer = [];
linterProcess.stdout.on('data', (message) => {
if (message) {
const msg = message.toString();
for (let line of msg.split('\n')) {
const indexOfSeparator = line.indexOf(':');
if (indexOfSeparator > 0) {
const type = line.substring(0, indexOfSeparator);
const body = line.substring(indexOfSeparator + 1);
switch (type) {
case 'tslint': {
const json = JSON.parse(body);
for (let item of json) {
linterOutBuffer.push(item);
}
break;
}
case 'tsinfo': {
process.stdout.write(chalk.cyan(`[tslint-plugin] ${body}\n`));
break;
}
case 'tserror': {
process.stderr.write(chalk.red(`[tslint-plugin] ${body}\n`));
break;
}
default: {
process.stderr.write(msg);
}
}
} else {
process.stdout.write(line);
}
}
}
});
linterProcess.once('exit', () => {
resolve({ iteration: linterIteration, out: linterOutBuffer });
// Clean up the linterProcess when finished
delete linterProcess;
});
});
}
function createError(message) {
const error = new Error(message);
delete error.stackTrace;
return error;
}
function emitHook(compilation, callback) {
if (linterPromise && options.waitForLinting) {
linterPromise.then(result => {
for (let r of result.out) {
const msg = `${r.name}:${r.startPosition.line + 1}:${r.startPosition.character + 1} [tslint] ${r.ruleName}: ${r.failure}`;
if (r.ruleSeverity === 'ERROR' || options.warningsAsError) {
compilation.errors.push(createError(msg));
} else {
compilation.warnings.push(createError(msg));
}
}
callback();
});
} else {
callback();
}
}
function doneHook() {
const currentIteration = linterIteration;
if (linterPromise && !options.waitForLinting) {
let isResolved = false;
linterPromise.then(result => {
isResolved = true;
// If the iterations are not the same another process has already been started and we cancel these results.
if (result.iteration === currentIteration) {
for (let r of result.out) {
const msg = `${r.name}:${r.startPosition.line + 1}:${r.startPosition.character + 1} [tslint] ${r.ruleName}: ${r.failure}`;
if (r.ruleSeverity === 'ERROR' || options.warningsAsError) {
process.stderr.write(chalk.red(msg + '\n'));
} else {
process.stdout.write(chalk.yellow(msg + '\n'));
}
}
}
});
if (!isResolved) {
process.stdout.write(chalk.cyan(`[tslint-plugin] Waiting for results...\n`));
}
}
}
if (compiler.hooks) {
// Webpack 4
compiler.hooks.compile.tap('TSLintWebpackPlugin', compileHook);
compiler.hooks.emit.tapAsync('TSLintWebpackPlugin', emitHook);
compiler.hooks.done.tap('TSLintWebpackPlugin', doneHook);
} else {
// Backwards compatibility
compiler.plugin('compile', compileHook);
compiler.plugin('emit', emitHook);
compiler.plugin('done', doneHook);
}
}
module.exports = function TSLintWebpackPlugin(options = {}) {
return {
apply: apply.bind(this, options)
};
};

2
src/Squidex/app-config/webpack.run.dev.js

@ -6,7 +6,7 @@
const plugins = { const plugins = {
// https://github.com/jrparish/tslint-webpack-plugin // https://github.com/jrparish/tslint-webpack-plugin
TsLintPlugin: require('./tslint/plugin') TsLintPlugin: require('tslint-webpack-plugin')
}; };
module.exports = webpackMerge(runConfig, { module.exports = webpackMerge(runConfig, {

2
src/Squidex/app-config/webpack.run.prod.js

@ -14,7 +14,7 @@ const plugins = {
// https://github.com/NMFR/optimize-css-assets-webpack-plugin // https://github.com/NMFR/optimize-css-assets-webpack-plugin
OptimizeCSSAssetsPlugin: require("optimize-css-assets-webpack-plugin"), OptimizeCSSAssetsPlugin: require("optimize-css-assets-webpack-plugin"),
// https://github.com/jrparish/tslint-webpack-plugin // https://github.com/jrparish/tslint-webpack-plugin
TsLintPlugin: require('./tslint/plugin') TsLintPlugin: require('tslint-webpack-plugin')
}; };
helpers.removeLoaders(runConfig, ['scss', 'ts']); helpers.removeLoaders(runConfig, ['scss', 'ts']);

1013
src/Squidex/package-lock.json

File diff suppressed because it is too large

20
src/Squidex/package.json

@ -27,7 +27,7 @@
"@angular/router": "7.1.4", "@angular/router": "7.1.4",
"angular2-chartjs": "0.5.1", "angular2-chartjs": "0.5.1",
"babel-polyfill": "6.26.0", "babel-polyfill": "6.26.0",
"bootstrap": "4.1.3", "bootstrap": "4.2.1",
"core-js": "2.6.1", "core-js": "2.6.1",
"graphiql": "0.12.0", "graphiql": "0.12.0",
"graphql": "14.0.2", "graphql": "14.0.2",
@ -35,7 +35,7 @@
"mousetrap": "1.6.2", "mousetrap": "1.6.2",
"ng2-dnd": "5.0.2", "ng2-dnd": "5.0.2",
"ngx-color-picker": "7.2.0", "ngx-color-picker": "7.2.0",
"oidc-client": "1.6.0", "oidc-client": "1.6.1",
"pikaday": "1.8.0", "pikaday": "1.8.0",
"progressbar.js": "1.0.1", "progressbar.js": "1.0.1",
"react": "16.7.0", "react": "16.7.0",
@ -51,19 +51,19 @@
"@angular/compiler-cli": "7.1.4", "@angular/compiler-cli": "7.1.4",
"@ngtools/webpack": "7.1.4", "@ngtools/webpack": "7.1.4",
"@types/core-js": "2.5.0", "@types/core-js": "2.5.0",
"@types/jasmine": "3.3.4", "@types/jasmine": "3.3.5",
"@types/mousetrap": "1.6", "@types/mousetrap": "1.6",
"@types/node": "10.12.18", "@types/node": "10.12.18",
"@types/react": "16.7.17", "@types/react": "16.7.18",
"@types/react-dom": "16.0.11", "@types/react-dom": "16.0.11",
"@types/sortablejs": "1.7.1", "@types/sortablejs": "1.7.2",
"angular-router-loader": "0.8.5", "angular-router-loader": "0.8.5",
"angular2-template-loader": "0.6.2", "angular2-template-loader": "0.6.2",
"awesome-typescript-loader": "5.2.1", "awesome-typescript-loader": "5.2.1",
"babel-core": "6.26.3", "babel-core": "6.26.3",
"codelyzer": "4.5.0", "codelyzer": "4.5.0",
"cpx": "1.5.0", "cpx": "1.5.0",
"css-loader": "2.0.1", "css-loader": "2.1.0",
"file-loader": "3.0.1", "file-loader": "3.0.1",
"html-loader": "0.5.5", "html-loader": "0.5.5",
"html-webpack-plugin": "3.2.0", "html-webpack-plugin": "3.2.0",
@ -91,14 +91,14 @@
"style-loader": "0.23.1", "style-loader": "0.23.1",
"tsconfig-paths-webpack-plugin": "3.2.0", "tsconfig-paths-webpack-plugin": "3.2.0",
"tslint": "5.12.0", "tslint": "5.12.0",
"tslint-webpack-plugin": "1.3.0", "tslint-webpack-plugin": "2.0.0",
"typemoq": "2.1.0", "typemoq": "2.1.0",
"typescript": "3.1.1", "typescript": "3.1.1",
"uglifyjs-webpack-plugin": "2.0.1", "uglifyjs-webpack-plugin": "2.1.1",
"underscore": "1.9.1", "underscore": "1.9.1",
"webpack": "4.28.1", "webpack": "4.28.2",
"webpack-cli": "3.1.2", "webpack-cli": "3.1.2",
"webpack-dev-server": "3.1.10", "webpack-dev-server": "3.1.14",
"webpack-merge": "4.1.5" "webpack-merge": "4.1.5"
} }
} }

Loading…
Cancel
Save