@bmatei/eslint-builder-angular
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "@bmatei/eslint-builder-angular", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "ESLint builder for Angular.", | ||
"keywords": [ | ||
"angular", | ||
"angular-cli", | ||
"codelyzer", | ||
"eslint", | ||
"lint", | ||
"typescript" | ||
], | ||
"author": "Bogdan Matei <bogdan@matei.dev>", | ||
@@ -6,0 +14,0 @@ "license": "MIT", |
@@ -1,2 +0,1 @@ | ||
# ESLint builder for Angular | ||
@@ -29,6 +28,7 @@ Run [ESLint](https://eslint.org/) from Angular CLI. | ||
- [Reference: fix](https://eslint.org/docs/developer-guide/nodejs-api#cliengine) | ||
6. `format` | ||
6. `force` | ||
- Ignore any errors and warnings and return a success status. | ||
- Default: `false` | ||
7. `format` | ||
- [Reference: format](https://eslint.org/docs/developer-guide/nodejs-api#cliengine) | ||
7. `force` | ||
- Ignore any errors and warnings and return a success status. | ||
8. `reportUnusedDisableDirectives` | ||
@@ -35,0 +35,0 @@ - [Reference: reportUnusedDisableDirectives](https://eslint.org/docs/developer-guide/nodejs-api#cliengine) |
@@ -6,2 +6,3 @@ "use strict"; | ||
const load_project_eslint_1 = require("./load-project-eslint"); | ||
const should_print_info_1 = require("./should-print-info"); | ||
function builder(options, context) { | ||
@@ -12,4 +13,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const projectName = (context.target && context.target.project) || '<???>'; | ||
// Print formatter output only for non human-readable formats. | ||
const printInfo = !options.silent && options.format !== 'json'; | ||
const printInfo = should_print_info_1.shouldPrintInfo(options); | ||
let status = `Running ESLint for project ${JSON.stringify(projectName)}...`; | ||
@@ -22,12 +22,12 @@ context.reportStatus(status); | ||
options.cwd = systemRoot; | ||
const result = lint_1.lint(projectEslint, options); | ||
const report = lint_1.lint(projectEslint, options); | ||
if (printInfo) { | ||
context.logger.info(result.output); | ||
if (result.hasWarnings) { | ||
context.logger.info(report.output); | ||
if (report.hasWarnings) { | ||
context.logger.warn('ESLint found warnings in the listed files.'); | ||
} | ||
if (result.hasErrors) { | ||
if (report.hasErrors) { | ||
context.logger.error('ESLint found errors in the listed files.'); | ||
} | ||
if (result.isSuccess) { | ||
if (report.isSuccess) { | ||
context.logger.info('All files passed linting with ESLint.'); | ||
@@ -37,3 +37,3 @@ } | ||
return { | ||
success: options.force || result.isSuccess | ||
success: options.force ? true : report.isSuccess | ||
}; | ||
@@ -40,0 +40,0 @@ }); |
import { json } from '@angular-devkit/core'; | ||
import * as SchemaBuilderOptions from './schema.json'; | ||
export declare type BuilderOptions = typeof SchemaBuilderOptions & json.JsonObject; | ||
export interface LintResult { | ||
export interface LintReport { | ||
output: string; | ||
hasWarnings: boolean; | ||
hasErrors: boolean; | ||
isSuccess: boolean; | ||
} | ||
export declare enum Severity { | ||
WARN = 1, | ||
ERROR = 2 | ||
} | ||
export interface WarningsErrorsFlags { | ||
hasWarnings: boolean; | ||
hasErrors: boolean; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Severity; | ||
(function (Severity) { | ||
Severity[Severity["WARN"] = 1] = "WARN"; | ||
Severity[Severity["ERROR"] = 2] = "ERROR"; | ||
})(Severity = exports.Severity || (exports.Severity = {})); | ||
//# sourceMappingURL=builder.model.js.map |
import * as eslint from 'eslint'; | ||
import { BuilderOptions, LintResult } from './builder.model'; | ||
export declare function lint(projectEslint: typeof eslint, options: BuilderOptions): LintResult; | ||
import { BuilderOptions, LintReport } from './builder.model'; | ||
export declare function lint(projectEslint: typeof eslint, options: BuilderOptions): LintReport; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Severity; | ||
(function (Severity) { | ||
Severity[Severity["WARN"] = 1] = "WARN"; | ||
Severity[Severity["ERROR"] = 2] = "ERROR"; | ||
})(Severity || (Severity = {})); | ||
const get_warning_errors_flags_1 = require("./get-warning-errors-flags"); | ||
function lint(projectEslint, options) { | ||
@@ -12,9 +8,3 @@ const cliEngine = new projectEslint.CLIEngine(options); | ||
const report = cliEngine.executeOnFiles(options.files); | ||
const warningErrorsFlags = report.results.map((result) => result.messages).flat().reduce((acc, message) => ({ | ||
hasWarnings: acc.hasWarnings || message.severity === Severity.WARN, | ||
hasErrors: acc.hasErrors || message.severity === Severity.ERROR | ||
}), { | ||
hasWarnings: false, | ||
hasErrors: false | ||
}); | ||
const warningErrorsFlags = get_warning_errors_flags_1.getWarningErrorsFlags(report); | ||
return Object.assign(Object.assign({ output: formatter(report.results) }, warningErrorsFlags), { isSuccess: !warningErrorsFlags.hasWarnings && !warningErrorsFlags.hasErrors }); | ||
@@ -21,0 +11,0 @@ } |
@@ -31,2 +31,6 @@ { | ||
}, | ||
"force": { | ||
"type": "boolean", | ||
"description": "Succeeds even if there was linting errors." | ||
}, | ||
"format": { | ||
@@ -50,6 +54,2 @@ "type": "string", | ||
}, | ||
"force": { | ||
"type": "boolean", | ||
"description": "Succeeds even if there was linting errors." | ||
}, | ||
"reportUnusedDisableDirectives": { | ||
@@ -56,0 +56,0 @@ "type": "boolean", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
15622
25
214