@angular-eslint/utils 15.1.1-alpha.9 → 15.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/convert-annotated-source-to-failure-case.d.ts +5 -5
- package/dist/eslint-plugin/ast-utils.d.ts +5 -5
- package/dist/eslint-plugin/selector-utils.d.ts +6 -5
- package/dist/eslint-plugin/selector-utils.js +12 -1
- package/dist/rules-tester.d.ts +2 -2
- package/dist/rules-tester.js +8 -4
- package/package.json +4 -4
|
@@ -9,24 +9,24 @@ import type { TSESLint } from '@typescript-eslint/utils';
|
|
|
9
9
|
* See the convertAnnotatedSourceToFailureCase() utility itself for more details.
|
|
10
10
|
*/
|
|
11
11
|
export declare const SPECIAL_UNDERLINE_CHARS: readonly ["~", "^", "#", "%", "¶", "*", "¨", "@"];
|
|
12
|
-
|
|
12
|
+
type MultipleErrorOptions<TMessageIds extends string> = BaseErrorOptions & {
|
|
13
13
|
readonly messages: readonly (Message<TMessageIds> & {
|
|
14
|
-
readonly char: typeof SPECIAL_UNDERLINE_CHARS[number];
|
|
14
|
+
readonly char: (typeof SPECIAL_UNDERLINE_CHARS)[number];
|
|
15
15
|
})[];
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
type BaseErrorOptions = {
|
|
18
18
|
readonly description: string;
|
|
19
19
|
readonly annotatedSource: string;
|
|
20
20
|
readonly options?: readonly unknown[];
|
|
21
21
|
readonly annotatedOutput?: string;
|
|
22
22
|
readonly filename?: string;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
type Message<TMessageIds extends string> = {
|
|
25
25
|
readonly messageId: TMessageIds;
|
|
26
26
|
readonly data?: Record<string, unknown>;
|
|
27
27
|
readonly suggestions?: TSESLint.SuggestionOutput<TMessageIds>[];
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
type SingleErrorOptions<TMessageIds extends string> = BaseErrorOptions & Message<TMessageIds>;
|
|
30
30
|
/**
|
|
31
31
|
* convertAnnotatedSourceToFailureCase() provides an ergonomic way to easily write
|
|
32
32
|
* expected failure cases for ESLint rules by allowing you to directly annotate the
|
|
@@ -66,11 +66,11 @@ export declare enum AngularLifecycleMethods {
|
|
|
66
66
|
}
|
|
67
67
|
export declare const OPTION_STYLE_CAMEL_CASE = "camelCase";
|
|
68
68
|
export declare const OPTION_STYLE_KEBAB_CASE = "kebab-case";
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
69
|
+
export type SelectorStyle = typeof OPTION_STYLE_CAMEL_CASE | typeof OPTION_STYLE_KEBAB_CASE;
|
|
70
|
+
export type AngularClassDecoratorKeys = keyof typeof AngularClassDecorators;
|
|
71
|
+
export type AngularInnerClassDecoratorKeys = Exclude<keyof typeof AngularInnerClassDecorators, number>;
|
|
72
|
+
export type AngularLifecycleInterfaceKeys = keyof typeof AngularLifecycleInterfaces;
|
|
73
|
+
export type AngularLifecycleMethodKeys = keyof typeof AngularLifecycleMethods;
|
|
74
74
|
export declare const angularClassDecoratorKeys: readonly ("Component" | "Directive" | "Injectable" | "NgModule" | "Pipe")[];
|
|
75
75
|
export declare const angularInnerClassDecoratorKeys: readonly ("ContentChild" | "ContentChildren" | "HostBinding" | "Input" | "Output" | "ViewChild" | "ViewChildren" | "HostListener" | "Attribute" | "Host" | "Inject" | "Optional" | "Self" | "SkipSelf")[];
|
|
76
76
|
export declare const angularLifecycleInterfaceKeys: readonly ("AfterContentChecked" | "AfterContentInit" | "AfterViewChecked" | "AfterViewInit" | "DoBootstrap" | "DoCheck" | "OnChanges" | "OnDestroy" | "OnInit")[];
|
|
@@ -3,10 +3,10 @@ import type { SelectorStyle } from './ast-utils';
|
|
|
3
3
|
export declare const OPTION_TYPE_ATTRIBUTE = "attribute";
|
|
4
4
|
export declare const OPTION_TYPE_ATTRS = "attrs";
|
|
5
5
|
export declare const OPTION_TYPE_ELEMENT = "element";
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
6
|
+
export type SelectorStyleOption = SelectorStyle | string;
|
|
7
|
+
export type SelectorTypeOption = typeof OPTION_TYPE_ATTRIBUTE | typeof OPTION_TYPE_ELEMENT | string;
|
|
8
|
+
export type SelectorTypeInternal = typeof OPTION_TYPE_ATTRS | typeof OPTION_TYPE_ELEMENT;
|
|
9
|
+
export type Options = [
|
|
10
10
|
{
|
|
11
11
|
readonly type: SelectorTypeOption | readonly SelectorTypeOption[];
|
|
12
12
|
readonly prefix: string | readonly string[];
|
|
@@ -18,10 +18,11 @@ export declare const SelectorValidator: {
|
|
|
18
18
|
camelCase(selector: string): boolean;
|
|
19
19
|
element(selector: string): boolean;
|
|
20
20
|
kebabCase(selector: string): boolean;
|
|
21
|
-
prefix(prefix: string, selectorStyle:
|
|
21
|
+
prefix(prefix: string, selectorStyle: string): (selector: string) => boolean;
|
|
22
22
|
};
|
|
23
23
|
export declare const reportPrefixError: (node: TSESTree.Node, prefix: string | readonly string[], context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>) => void;
|
|
24
24
|
export declare const reportStyleError: (node: TSESTree.Node, style: SelectorStyleOption, context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>) => void;
|
|
25
|
+
export declare const reportStyleAndPrefixError: (node: TSESTree.Node, style: SelectorStyleOption, prefix: string | readonly string[], context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>) => void;
|
|
25
26
|
export declare const reportTypeError: (node: TSESTree.Node, type: SelectorTypeOption | readonly SelectorTypeOption[], context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>) => void;
|
|
26
27
|
export declare const checkValidOptions: (type: SelectorTypeOption | readonly SelectorTypeOption[], prefix: string | readonly string[], style: SelectorStyleOption) => boolean;
|
|
27
28
|
export declare const checkSelector: (node: TSESTree.Node, typeOption: SelectorTypeOption | readonly SelectorTypeOption[], prefixOption: readonly string[], styleOption: SelectorStyle) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkSelector = exports.checkValidOptions = exports.reportTypeError = exports.reportStyleError = exports.reportPrefixError = exports.SelectorValidator = exports.OPTION_TYPE_ELEMENT = exports.OPTION_TYPE_ATTRS = exports.OPTION_TYPE_ATTRIBUTE = void 0;
|
|
3
|
+
exports.checkSelector = exports.checkValidOptions = exports.reportTypeError = exports.reportStyleAndPrefixError = exports.reportStyleError = exports.reportPrefixError = exports.SelectorValidator = exports.OPTION_TYPE_ELEMENT = exports.OPTION_TYPE_ATTRS = exports.OPTION_TYPE_ATTRIBUTE = void 0;
|
|
4
4
|
const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-compiler");
|
|
5
5
|
const ast_utils_1 = require("./ast-utils");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
@@ -71,6 +71,17 @@ const reportStyleError = (node, style, context) => {
|
|
|
71
71
|
});
|
|
72
72
|
};
|
|
73
73
|
exports.reportStyleError = reportStyleError;
|
|
74
|
+
const reportStyleAndPrefixError = (node, style, prefix, context) => {
|
|
75
|
+
context.report({
|
|
76
|
+
node,
|
|
77
|
+
messageId: 'styleAndPrefixFailure',
|
|
78
|
+
data: {
|
|
79
|
+
style,
|
|
80
|
+
prefix: (0, utils_1.toHumanReadableText)((0, utils_1.arrayify)(prefix)),
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
exports.reportStyleAndPrefixError = reportStyleAndPrefixError;
|
|
74
85
|
const reportTypeError = (node, type, context) => {
|
|
75
86
|
context.report({
|
|
76
87
|
node,
|
package/dist/rules-tester.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
2
|
declare const VALID_PARSERS: readonly ["@angular-eslint/template-parser", "@typescript-eslint/parser"];
|
|
3
|
-
|
|
4
|
-
parser: typeof VALID_PARSERS[number];
|
|
3
|
+
type RuleTesterConfig = Omit<TSESLint.RuleTesterConfig, 'parser'> & {
|
|
4
|
+
parser: (typeof VALID_PARSERS)[number];
|
|
5
5
|
};
|
|
6
6
|
export declare class RuleTester extends TSESLint.RuleTester {
|
|
7
7
|
private filename?;
|
package/dist/rules-tester.js
CHANGED
|
@@ -41,10 +41,10 @@ class RuleTester extends utils_1.TSESLint.RuleTester {
|
|
|
41
41
|
// but that's not as clean to type, this saves us trying to manually enforce
|
|
42
42
|
// that contributors require.resolve everything
|
|
43
43
|
constructor(options) {
|
|
44
|
-
var _a;
|
|
44
|
+
var _a, _b, _c;
|
|
45
45
|
super(Object.assign(Object.assign({}, options), { parser: require.resolve(options.parser) }));
|
|
46
46
|
if ((_a = options.parserOptions) === null || _a === void 0 ? void 0 : _a.project) {
|
|
47
|
-
this.filename = path.join(getFixturesRootDir(), 'file.ts');
|
|
47
|
+
this.filename = path.join((_c = (_b = options.parserOptions) === null || _b === void 0 ? void 0 : _b.tsconfigRootDir) !== null && _c !== void 0 ? _c : getFixturesRootDir(), 'file.ts');
|
|
48
48
|
}
|
|
49
49
|
// make sure that the parser doesn't hold onto file handles between tests
|
|
50
50
|
// on linux (i.e. our CI env), there can be very a limited number of watch handles available
|
|
@@ -67,16 +67,20 @@ class RuleTester extends utils_1.TSESLint.RuleTester {
|
|
|
67
67
|
const errorMessage = `Do not set the parser at the test level unless you want to use a parser other than ${VALID_PARSERS.join(', ')}`;
|
|
68
68
|
const parsedTests = {
|
|
69
69
|
valid: valid.map((test) => {
|
|
70
|
+
var _a;
|
|
70
71
|
if (typeof test !== 'string' && isValidParser(test.parser)) {
|
|
71
72
|
throw Error(errorMessage);
|
|
72
73
|
}
|
|
73
|
-
return
|
|
74
|
+
return typeof test === 'string'
|
|
75
|
+
? { code: test, filename: this.filename }
|
|
76
|
+
: Object.assign(Object.assign({}, test), { filename: (_a = test.filename) !== null && _a !== void 0 ? _a : this.filename });
|
|
74
77
|
}),
|
|
75
78
|
invalid: invalid.map((test) => {
|
|
79
|
+
var _a;
|
|
76
80
|
if (isValidParser(test.parser)) {
|
|
77
81
|
throw Error(errorMessage);
|
|
78
82
|
}
|
|
79
|
-
return Object.assign(Object.assign({}, test), { filename: this.filename });
|
|
83
|
+
return Object.assign(Object.assign({}, test), { filename: (_a = test.filename) !== null && _a !== void 0 ? _a : this.filename });
|
|
80
84
|
}),
|
|
81
85
|
};
|
|
82
86
|
super.run(name, rule, parsedTests);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/utils",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"typescript": "*"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@angular-eslint/bundled-angular-compiler": "15.
|
|
19
|
-
"@typescript-eslint/utils": "5.
|
|
18
|
+
"@angular-eslint/bundled-angular-compiler": "15.2.0",
|
|
19
|
+
"@typescript-eslint/utils": "5.48.1"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "e48f172aea96f6e4c6b80d8ff06e8c004caf7775"
|
|
22
22
|
}
|