@terra-symposium/standards-quality 0.0.0-stage → 0.5.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/README.md +89 -2
- package/dist/collapse.d.ts +13 -0
- package/dist/collapse.d.ts.map +1 -0
- package/dist/collapse.js +151 -0
- package/dist/collapse.js.map +1 -0
- package/dist/documentation.d.ts +84 -0
- package/dist/documentation.d.ts.map +1 -0
- package/dist/documentation.js +1244 -0
- package/dist/documentation.js.map +1 -0
- package/dist/files.d.ts +39 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +90 -0
- package/dist/files.js.map +1 -0
- package/dist/github-report.d.ts +89 -0
- package/dist/github-report.d.ts.map +1 -0
- package/dist/github-report.js +469 -0
- package/dist/github-report.js.map +1 -0
- package/dist/history-report.d.ts +52 -0
- package/dist/history-report.d.ts.map +1 -0
- package/dist/history-report.js +317 -0
- package/dist/history-report.js.map +1 -0
- package/dist/imports.d.ts +19 -0
- package/dist/imports.d.ts.map +1 -0
- package/dist/imports.js +90 -0
- package/dist/imports.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/inline-if.d.ts +13 -0
- package/dist/inline-if.d.ts.map +1 -0
- package/dist/inline-if.js +48 -0
- package/dist/inline-if.js.map +1 -0
- package/dist/naming.d.ts +148 -0
- package/dist/naming.d.ts.map +1 -0
- package/dist/naming.js +642 -0
- package/dist/naming.js.map +1 -0
- package/dist/object-forwarding.d.ts +44 -0
- package/dist/object-forwarding.d.ts.map +1 -0
- package/dist/object-forwarding.js +182 -0
- package/dist/object-forwarding.js.map +1 -0
- package/dist/patterns.d.ts +85 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/patterns.js +905 -0
- package/dist/patterns.js.map +1 -0
- package/dist/port.d.ts +21 -0
- package/dist/port.d.ts.map +1 -0
- package/dist/port.js +81 -0
- package/dist/port.js.map +1 -0
- package/dist/progress.d.ts +16 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +30 -0
- package/dist/progress.js.map +1 -0
- package/dist/runner.d.ts +257 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +2481 -0
- package/dist/runner.js.map +1 -0
- package/dist/security.d.ts +19 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +76 -0
- package/dist/security.js.map +1 -0
- package/dist/single-use.d.ts +60 -0
- package/dist/single-use.d.ts.map +1 -0
- package/dist/single-use.js +1209 -0
- package/dist/single-use.js.map +1 -0
- package/package.json +45 -5
- package/quality.schema.json +130 -0
package/dist/naming.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/quality/src/naming.ts
|
|
3
|
+
* Renames identifiers according to the configured replacement rules.
|
|
4
|
+
*/
|
|
5
|
+
import ts from 'typescript';
|
|
6
|
+
import type { QualityAnalysis, QualityCfg } from './runner.js';
|
|
7
|
+
/** Context used when shortening an identifier without changing its meaning. */
|
|
8
|
+
type RenameKind = {
|
|
9
|
+
numericIndex?: boolean;
|
|
10
|
+
callback?: boolean;
|
|
11
|
+
reserved?: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare const IDENTIFIER_REPLACEMENTS: Readonly<Record<string, string>>;
|
|
14
|
+
export declare const PREFIX_REPLACEMENTS: Readonly<Record<string, string>>;
|
|
15
|
+
export declare const CALLBACK_ALIASES: Readonly<Record<string, string>>;
|
|
16
|
+
export declare const CALLBACK_METHODS: Set<string>;
|
|
17
|
+
export declare const PROTECTED_IDENTIFIERS: Set<string>;
|
|
18
|
+
export declare const PROTECTED_PATH_PARTS: Set<string>;
|
|
19
|
+
export declare const PROTECTED_FILENAMES: Set<string>;
|
|
20
|
+
export declare const CODE_EXTS: Set<string>;
|
|
21
|
+
/** A naming issue or concise-name suggestion found in one source file. */
|
|
22
|
+
export type NamingFinding = {
|
|
23
|
+
file: string;
|
|
24
|
+
name: string;
|
|
25
|
+
suggestion: string;
|
|
26
|
+
severity: 'error' | 'warning';
|
|
27
|
+
start: number;
|
|
28
|
+
};
|
|
29
|
+
/** A declaration that only gives an existing symbol a second local name. */
|
|
30
|
+
export type AliasFinding = {
|
|
31
|
+
file: string;
|
|
32
|
+
line: number;
|
|
33
|
+
kind: 'const' | 'type';
|
|
34
|
+
name: string;
|
|
35
|
+
replacement: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Splits an identifier into words while preserving acronym and numeric boundaries.
|
|
39
|
+
*
|
|
40
|
+
* @param name Identifier to tokenize.
|
|
41
|
+
*
|
|
42
|
+
* @return Identifier word tokens in source order.
|
|
43
|
+
*/
|
|
44
|
+
export declare function identifierTokens(name: string): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Chooses the preferred one-letter alias for a callback parameter without colliding with local names.
|
|
47
|
+
*
|
|
48
|
+
* @param name Existing callback parameter name.
|
|
49
|
+
* @param reserved Names already used in the callback scope.
|
|
50
|
+
*
|
|
51
|
+
* @return A concise available callback alias.
|
|
52
|
+
*/
|
|
53
|
+
export declare function callbackAlias(name: string, reserved?: string[]): string;
|
|
54
|
+
/**
|
|
55
|
+
* Produces the configured concise form of an identifier, including callback and numeric-index aliases.
|
|
56
|
+
*
|
|
57
|
+
* @param name Identifier to shorten.
|
|
58
|
+
* @param kind Context flags controlling callback, index, and reserved-name handling.
|
|
59
|
+
*
|
|
60
|
+
* @return Concise identifier, or the original name when no safe replacement applies.
|
|
61
|
+
*/
|
|
62
|
+
export declare function renameId(name: string, kind?: RenameKind): string;
|
|
63
|
+
/**
|
|
64
|
+
* Returns whether a declaration belongs to a supported callback.
|
|
65
|
+
*
|
|
66
|
+
* @param node Identifier declaration to inspect.
|
|
67
|
+
*
|
|
68
|
+
* @return `true` when the declaration is a supported callback parameter.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isCallbackDeclaration(node: ts.Identifier): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the context-aware concise suggestion for one repository-owned declaration.
|
|
73
|
+
*
|
|
74
|
+
* @param n Identifier declaration whose context determines the suggestion.
|
|
75
|
+
*
|
|
76
|
+
* @return Concise name appropriate for the declaration's scope and callback role.
|
|
77
|
+
*/
|
|
78
|
+
export declare function renameDeclaration(n: ts.Identifier): string;
|
|
79
|
+
/**
|
|
80
|
+
* Checks whether an identifier starts with a configured prefix replacement.
|
|
81
|
+
*
|
|
82
|
+
* @param name Identifier to inspect.
|
|
83
|
+
*
|
|
84
|
+
* @return `true` when its first token has a configured concise prefix.
|
|
85
|
+
*/
|
|
86
|
+
export declare function hasPrefixReplacement(name: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Checks whether a path is protected from symbol renaming because it is generated or framework-owned.
|
|
89
|
+
*
|
|
90
|
+
* @param fileName Path to inspect.
|
|
91
|
+
*
|
|
92
|
+
* @return `true` for declaration files and configured protected path segments.
|
|
93
|
+
*/
|
|
94
|
+
export declare function isProtectedPath(fileName: string): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Checks whether a filename is a framework convention whose declarations must retain their names.
|
|
97
|
+
*
|
|
98
|
+
* @param fileName Path or basename to inspect.
|
|
99
|
+
*
|
|
100
|
+
* @return `true` when the basename is a protected route or component filename.
|
|
101
|
+
*/
|
|
102
|
+
export declare function isProtectedFilename(fileName: string): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Reports whether an identifier already satisfies the configured concise-name rules.
|
|
105
|
+
*
|
|
106
|
+
* @param name Identifier to validate.
|
|
107
|
+
* @param kind Context flags used when the identifier is a callback or index parameter.
|
|
108
|
+
*
|
|
109
|
+
* @return `true` when renaming would produce the same identifier.
|
|
110
|
+
*/
|
|
111
|
+
export declare function isApprovedId(name: string, kind?: RenameKind): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Returns whether an identifier declares a repository-owned symbol safe to rename with all references.
|
|
114
|
+
*
|
|
115
|
+
* @param n Identifier declaration to classify.
|
|
116
|
+
*
|
|
117
|
+
* @return `true` when all references can be updated as a repository-local rename.
|
|
118
|
+
*/
|
|
119
|
+
export declare function isRenamableDeclaration(n: ts.Identifier): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Returns the function or source-file scope that owns a declaration.
|
|
122
|
+
*
|
|
123
|
+
* @param n Identifier whose owning function or source-file scope is required.
|
|
124
|
+
*
|
|
125
|
+
* @return The nearest function-like scope, or the source file when no function owns it.
|
|
126
|
+
*/
|
|
127
|
+
export declare function declarationScope(n: ts.Identifier): ts.Node;
|
|
128
|
+
/**
|
|
129
|
+
* Reports concise-name drift without mutating the consumer repository.
|
|
130
|
+
*
|
|
131
|
+
* @param cfg Quality configuration defining source scope and naming protections.
|
|
132
|
+
* @param analysis Optional shared program and source cache for the current quality run.
|
|
133
|
+
*
|
|
134
|
+
* @return Concise-name findings for declarations that can be renamed safely.
|
|
135
|
+
*/
|
|
136
|
+
export declare function namingFindings(cfg: QualityCfg, analysis?: QualityAnalysis): NamingFinding[];
|
|
137
|
+
/**
|
|
138
|
+
* Finds and optionally removes declarations that only rename another symbol.
|
|
139
|
+
*
|
|
140
|
+
* @param cfg Quality configuration defining the source scope and protected identifiers.
|
|
141
|
+
* @param analysisOrFix Shared analysis context, or the legacy boolean autofix flag.
|
|
142
|
+
* @param legacyFix Autofix flag used when an analysis context is supplied.
|
|
143
|
+
*
|
|
144
|
+
* @return Alias declarations that can be removed, whether or not autofix is enabled.
|
|
145
|
+
*/
|
|
146
|
+
export declare function aliasFindings(cfg: QualityCfg, analysisOrFix?: QualityAnalysis | boolean, legacyFix?: boolean): AliasFinding[];
|
|
147
|
+
export {};
|
|
148
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../src/naming.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5B,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM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