🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

@krema/angular-eslint-stylelint-builder

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@krema/angular-eslint-stylelint-builder - npm Package Compare versions

Comparing version

to
2.0.0

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.builder = void 0;
exports.builder = builder;
const eslint = require("./eslint/eslint-linter");

@@ -19,5 +19,5 @@ const stylelint = require("./stylelint/stylelint-linter");

function builder(options, context) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const projectName = ((_a = context === null || context === void 0 ? void 0 : context.target) === null || _a === void 0 ? void 0 : _a.project) || '<???>';
var _a, _b;
const projectName = (_b = (_a = context === null || context === void 0 ? void 0 : context.target) === null || _a === void 0 ? void 0 : _a.project) !== null && _b !== void 0 ? _b : '<???>';
const printInfo = options.format && !options.silent;

@@ -47,2 +47,1 @@ if (printInfo) {

}
exports.builder = builder;

@@ -12,3 +12,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createESlintInstance = exports.lint = void 0;
exports.lint = lint;
exports.createESlintInstance = createESlintInstance;
const path_1 = require("path");

@@ -26,5 +27,5 @@ const eslint_utils_1 = require("./eslint-utils");

}
exports.lint = lint;
function createESlintInstance(workspaceRoot, options) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c;
(0, eslint_utils_1.checkESlintVersion)();

@@ -37,11 +38,7 @@ /**

const eslintOptions = {
useEslintrc: !options.noEslintrc,
overrideConfigFile: configPath,
ignorePath: options.eslintIgnorePath || undefined,
fix: !!options.fix,
cache: !!options.eslintCache,
cacheLocation: options.eslintCacheLocation || undefined,
cacheStrategy: options.eslintCacheStrategy || undefined,
resolvePluginsRelativeTo: options.eslintResolvePluginsRelativeTo || undefined,
rulePaths: options.eslintRulesDir || [],
cacheLocation: (_a = options.eslintCacheLocation) !== null && _a !== void 0 ? _a : undefined,
cacheStrategy: (_b = options.eslintCacheStrategy) !== null && _b !== void 0 ? _b : undefined,
/**

@@ -55,2 +52,3 @@ * Default is `true` and if not overridden the eslint.lintFiles() method will throw an error

errorOnUnmatchedPattern: false,
ignorePatterns: (_c = options.eslintIgnorePatterns) !== null && _c !== void 0 ? _c : [],
};

@@ -61,2 +59,1 @@ const projectESLint = yield (0, eslint_utils_1.loadESLint)();

}
exports.createESlintInstance = createESlintInstance;

@@ -12,3 +12,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.filterLintResults = exports.outputFixes = exports.checkESlintVersion = exports.loadESLint = void 0;
exports.loadESLint = loadESLint;
exports.checkESlintVersion = checkESlintVersion;
exports.outputFixes = outputFixes;
exports.filterLintResults = filterLintResults;
function loadESLint() {

@@ -26,6 +29,5 @@ return __awaiter(this, void 0, void 0, function* () {

}
exports.loadESLint = loadESLint;
function checkESlintVersion() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const projectESLint = yield loadESLint();

@@ -41,3 +43,2 @@ const version = (_b = (_a = projectESLint.ESLint) === null || _a === void 0 ? void 0 : _a.version) === null || _b === void 0 ? void 0 : _b.split('.');

}
exports.checkESlintVersion = checkESlintVersion;
function outputFixes(lintResults) {

@@ -49,3 +50,2 @@ return __awaiter(this, void 0, void 0, function* () {

}
exports.outputFixes = outputFixes;
function filterLintResults(lintResults, options) {

@@ -78,2 +78,1 @@ const reportOnlyErrors = options.quiet;

}
exports.filterLintResults = filterLintResults;

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.report = void 0;
exports.report = report;
const fs_1 = require("fs");

@@ -35,3 +35,3 @@ const path_1 = require("path");

const formatter = yield eslintInstance.loadFormatter(options.format);
const formattedResults = formatter.format(finalLintResults.lintResults);
const formattedResults = yield formatter.format(finalLintResults.lintResults);
const printInfo = options.format && !options.silent;

@@ -66,2 +66,1 @@ const maxWarnings = options.maxWarnings;

}
exports.report = report;

@@ -1,2 +0,2 @@

declare const _default: import("@angular-devkit/architect/src/internal").Builder<any>;
declare const _default: import("@angular-devkit/architect").Builder<import("./schema").Schema & import("@angular-devkit/core").JsonObject>;
export default _default;

@@ -11,5 +11,3 @@ {

"default": [],
"items": {
"type": "string"
}
"items": { "type": "string" }
},

@@ -24,5 +22,3 @@ "eslintConfig": {

"default": [],
"items": {
"type": "string"
}
"items": { "type": "string" }
},

@@ -62,22 +58,12 @@ "stylelintConfig": {

},
"eslintIgnorePath": {
"type": "string",
"description": "A path to a file containing patterns describing files to ignore instead of $CWD/.eslintignore"
"eslintIgnorePatterns": {
"type": "array",
"items": { "type": "string" },
"description": "Array of glob patterns describing files to ignore for ESLint."
},
"stylelintIgnorePath": {
"type": "string",
"description": "A path to a file containing patterns describing files to ignore instead of $CWD/.stylelintignore"
},
"eslintRulesDir": {
"stylelintIgnorePatterns": {
"type": "array",
"description": "This option allows you to specify another directory from which to load rules files",
"default": [],
"items": {
"type": "string"
}
"items": { "type": "string" },
"description": "Array of glob patterns describing files to ignore for Stylelint."
},
"eslintResolvePluginsRelativeTo": {
"type": "string",
"description": "Changes the folder where plugins are resolved from"
},
"outputFile": {

@@ -131,3 +117,2 @@ "type": "string",

},
"noEslintrc": {

@@ -134,0 +119,0 @@ "type": "boolean",

@@ -12,8 +12,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.lint = void 0;
exports.lint = lint;
const path_1 = require("path");
const stylelint_utils_1 = require("./stylelint-utils");
function lint(context, options) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c, _d;
const workspaceRoot = context.workspaceRoot;

@@ -27,10 +27,10 @@ /**

cache: !!options.stylelintCache,
cacheLocation: options.stylelintCacheLocation || undefined,
cacheLocation: (_a = options.stylelintCacheLocation) !== null && _a !== void 0 ? _a : undefined,
fix: !!options.fix,
ignorePath: options.stylelintIgnorePath || undefined,
ignorePattern: (_b = options.stylelintIgnorePatterns) !== null && _b !== void 0 ? _b : [],
maxWarnings: options.maxWarnings,
configFile: configPath,
files: ((_a = options.stylelintFilePatterns) === null || _a === void 0 ? void 0 : _a.map(p => (0, path_1.normalize)((0, path_1.join)(workspaceRoot, p)).replace(/\\/g, '/'))) || [],
files: ((_c = options.stylelintFilePatterns) === null || _c === void 0 ? void 0 : _c.map(p => (0, path_1.normalize)((0, path_1.join)(workspaceRoot, p)).replace(/\\/g, '/'))) || [],
};
if (!((_b = stylelintOptions === null || stylelintOptions === void 0 ? void 0 : stylelintOptions.files) === null || _b === void 0 ? void 0 : _b.length)) {
if (!((_d = stylelintOptions === null || stylelintOptions === void 0 ? void 0 : stylelintOptions.files) === null || _d === void 0 ? void 0 : _d.length)) {
return [];

@@ -44,2 +44,1 @@ }

}
exports.lint = lint;
import type { ESLint } from 'eslint';
import type stylelint from 'stylelint';
import type { LinterResult } from 'stylelint';
import type { LinterResult } from 'stylelint/types/stylelint';
export declare function loadStylelint(): Promise<typeof stylelint>;
export declare function convertToLintResult(stylelintResults: LinterResult): ESLint.LintResult[];

@@ -12,3 +12,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.convertToLintResult = exports.loadStylelint = void 0;
exports.loadStylelint = loadStylelint;
exports.convertToLintResult = convertToLintResult;
function loadStylelint() {

@@ -25,20 +26,23 @@ return __awaiter(this, void 0, void 0, function* () {

}
exports.loadStylelint = loadStylelint;
function convertToLintResult(stylelintResults) {
return stylelintResults.results.map(result => ({
errorCount: result.warnings.length,
filePath: result.source,
fixableErrorCount: 0,
fixableWarningCount: 0,
usedDeprecatedRules: [],
warningCount: 0,
messages: result.warnings.map(warning => ({
column: warning.column,
line: warning.line,
message: warning.text,
ruleId: `stylelint\t${warning.rule}`,
severity: warning.severity === 'error' ? 2 : 1,
})),
}));
return stylelintResults.results.map(result => {
var _a;
return ({
errorCount: result.warnings.length,
filePath: (_a = result.source) !== null && _a !== void 0 ? _a : '',
fixableErrorCount: 0,
fixableWarningCount: 0,
usedDeprecatedRules: [],
warningCount: 0,
messages: result.warnings.map(warning => ({
column: warning.column,
line: warning.line,
message: warning.text,
ruleId: `stylelint\t${warning.rule}`,
severity: warning.severity === 'error' ? 2 : 1,
})),
suppressedMessages: [],
fatalErrorCount: 0,
});
});
}
exports.convertToLintResult = convertToLintResult;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDirectory = void 0;
exports.createDirectory = createDirectory;
const path_1 = require("path");

@@ -15,3 +15,2 @@ const fs_1 = require("fs");

}
exports.createDirectory = createDirectory;
function directoryExists(name) {

@@ -18,0 +17,0 @@ try {

@@ -5,3 +5,3 @@ {

"author": "André Kremser",
"version": "1.4.0",
"version": "2.0.0",
"license": "MIT",

@@ -8,0 +8,0 @@ "repository": {

@@ -1,19 +0,11 @@

# Angular ESLint + Stylelint Linter
[![npm version](https://badge.fury.io/js/@krema%2Fangular-eslint-stylelint-builder.svg)](https://badge.fury.io/js/@krema%2Fangular-eslint-stylelint-builder) ![node workflow](https://github.com/krema/angular-eslint-stylelint-builder/actions/workflows/integration-test.yml/badge.svg) ![node workflow](https://github.com/krema/angular-eslint-stylelint-builder/actions/workflows/unit-test.yml/badge.svg)
[![npm version](https://badge.fury.io/js/@krema%2Fangular-eslint-stylelint-builder.svg)](https://badge.fury.io/js/@krema%2Fangular-eslint-stylelint-builder) ![node workflow](https://github.com/krema/angular-eslint-stylelint-builder/actions/workflows/integration-test.yml/badge.svg) ![node workflow](https://github.com/krema/angular-eslint-stylelint-builder/actions/workflows/unit-test.yml/badge.svg) ![angular versions](https://img.shields.io/badge/angular-v9--v15-%2523DD0031.svg?flat-square&logo=angular&labelColor=ff0000&color=grey)
An Angular CLI builder inspired by [@angular-eslint/builder](https://github.com/angular-eslint/angular-eslint/tree/master/packages/builder) for linting Angular applications using [ESLint](https://eslint.org/) and [stylelint](https://stylelint.io/) in one easy step.
An Angular CLI builder inspired by [@angular-eslint/builder](https://github.com/angular-eslint/angular-eslint/tree/master/packages/builder) for linting Angular applications using [ESLint](https://eslint.org/) and [stylelint](https://stylelint.io/).
The library works with following Angular versions:
![9](https://img.shields.io/badge/angular-9-%23DD0031.svg?flat-square&logo=angular&labelColor=ff0000&color=grey) ![10](https://img.shields.io/badge/angular-10-%23DD0031.svg?flat-square&logo=angular&labelColor=ff0000&color=grey) ![11](https://img.shields.io/badge/angular-11-%23DD0031.svg?flat-square&logo=angular&labelColor=ff0000&color=grey) ![12](https://img.shields.io/badge/angular-12-%23DD0031.svg?flat-square&logo=angular&labelColor=ff0000&color=grey) ![13](https://img.shields.io/badge/angular-13-%23DD0031.svg?flat-square&logo=angular&labelColor=ff0000&color=grey) ![14](https://img.shields.io/badge/angular-14-%23DD0031.svg?flat-square&logo=angular&labelColor=ff0000&color=grey)
## Prerequisites
Installed and configured **eslint** and **stylelint** e.g. via `.eslintrc` and `.stylelintrc`.
Before using this linter, please ensure that you have already installed and configured **eslint** and **stylelint**, for example, by setting up `.eslintrc` and `.stylelintrc` files. For more information on converting TSLint to ESLint in Angular projects, please check out the [@angular-eslint](https://github.com/angular-eslint/angular-eslint) project.
For more information on converting TSLint to ESLint in Angular projects please see the following [@angular-eslint](https://github.com/angular-eslint/angular-eslint) project.
## Install

@@ -25,5 +17,4 @@

Add the builder *@krema/angular-eslint-stylelint-builder:lint"* to the lint task in your *angular.json*.
Add the builder `@krema/angular-eslint-stylelint-builder:lint` to the lint task in your *angular.json*.
**angular.json**

@@ -35,4 +26,3 @@

```diff
```diff
"lint": {

@@ -55,3 +45,3 @@ - "builder": "@angular-eslint/builder:lint",

The following options can be configured:
You can configure the following options:

@@ -83,3 +73,3 @@ <table>

<td>
Use this configuration, overriding .eslintrc.* config options if present
Use this configuration, overriding .eslintrc.*config options if present
</td>

@@ -176,7 +166,6 @@ <td></td>

<tr>
<td>eslintIgnorePath</td>
<td></td>
<td>eslintIgnorePatterns</td>
<td>[]</td>
<td>
A path to a file containing patterns describing files to ignore instead of
$CWD/.eslintignore
Array of glob patterns describing files to ignore (replaces <code>eslintIgnorePath</code> and <code>.eslintignore</code> in ESLint 9+)
</td>

@@ -187,7 +176,6 @@ <td></td>

<tr>
<td>stylelintIgnorePath</td>
<td></td>
<td>stylelintIgnorePatterns</td>
<td>[]</td>
<td>
A path to a file containing patterns describing files to ignore instead of
$CWD/.stylelintignore
Array of glob patterns describing files to ignore (replaces <code>stylelintIgnorePath</code> and <code>.stylelintignore</code> in Stylelint 16+)
</td>

@@ -198,19 +186,2 @@ <td></td>

<tr>
<td>eslintRulesDir</td>
<td>[]</td>
<td>
This option allows you to specify another directory from which to load
rules files
</td>
<td></td>
<td>eslint</td>
</tr>
<tr>
<td>eslintResolvePluginsRelativeTo</td>
<td></td>
<td>Changes the folder where plugins are resolved from</td>
<td></td>
<td>eslint</td>
</tr>
<tr>
<td colspan="5"><b>Output:</b></td>

@@ -217,0 +188,0 @@ </tr>