Skip to content

Commit 57d9118

Browse files
committed
Improve forbidden texts
1. Allow forbidden texts to be regexes 2. Update `check(` so require a function-like calling syntax 3. Remove `@glimmer/syntax` from `IGNORED_DIRS` by avoiding using `check` as an internal method.
1 parent 0d5ec41 commit 57d9118

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

bin/build-verify.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ const FORBIDDEN = [
1616
/**
1717
* These are for local VM debugging and development, and are not meant to make it to real code
1818
*/
19-
'check(',
19+
/[^.]check\(/,
2020
'CheckInterface',
2121
'CheckOr',
2222
'CheckFunction',
2323
'CheckObject',
2424
];
2525

26-
const IGNORED_DIRS = [`@glimmer/syntax`, `@glimmer/debug`];
26+
const IGNORED_DIRS = [`@glimmer/debug`];
2727

2828
let files = await globby(resolve(currentDir, '../../packages/**/dist/**/index.js'), {
2929
ignore: ['node_modules', '**/node_modules'],
@@ -41,7 +41,7 @@ for (let filePath of files) {
4141
let content = file.toString();
4242

4343
for (let searchFor of FORBIDDEN) {
44-
if (content.includes(searchFor)) {
44+
if (content.match(searchFor)) {
4545
errors.push({ filePath, found: searchFor });
4646
}
4747
}

packages/@glimmer/syntax/lib/source/loc/match.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ type ExhaustiveCheck<Out, In extends Matches, Removed extends Matches> = Exclude
9999
export type MatchFn<Out> = (left: PositionData, right: PositionData) => Out;
100100

101101
interface ExhaustiveMatcher<Out> {
102-
check(): MatchFn<Out>;
102+
validate(): MatchFn<Out>;
103103
}
104104

105105
export function match<Out>(callback: (m: Matcher<Out>) => ExhaustiveMatcher<Out>): MatchFn<Out> {
106-
return callback(new Matcher()).check();
106+
return callback(new Matcher()).validate();
107107
}
108108

109109
class Matcher<Out, M extends Matches = Matches> {
@@ -112,7 +112,7 @@ class Matcher<Out, M extends Matches = Matches> {
112112
/**
113113
* You didn't exhaustively match all possibilities.
114114
*/
115-
protected check(): MatchFn<Out> {
115+
protected validate(): MatchFn<Out> {
116116
return (left, right) => this.matchFor(left.kind, right.kind)(left, right);
117117
}
118118

packages/@glimmer/syntax/lib/source/loc/offset.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class SourceOffset {
104104
} else {
105105
const result = charPos.offset + by;
106106

107-
if (charPos.source.check(result)) {
107+
if (charPos.source.validate(result)) {
108108
return new CharPosition(charPos.source, result).wrap();
109109
} else {
110110
return SourceOffset.broken();

packages/@glimmer/syntax/lib/source/source.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Source {
1919
/**
2020
* Validate that the character offset represents a position in the source string.
2121
*/
22-
check(offset: number): boolean {
22+
validate(offset: number): boolean {
2323
return offset >= 0 && offset <= this.source.length;
2424
}
2525

0 commit comments

Comments
 (0)