Skip to content

Commit

Permalink
refactor(docs-infra): use tslint in aio's tools-lint script (#43010)
Browse files Browse the repository at this point in the history
Instead of the deprecated tslint use eslint in the aio's tools-lint
script

PR Close #43010
  • Loading branch information
dario-piotrowicz authored and TeriGlover committed Sep 22, 2021
1 parent f8a12b3 commit 55d11a8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 97 deletions.
2 changes: 1 addition & 1 deletion aio/package.json
Expand Up @@ -56,7 +56,7 @@
"docs-test": "node tools/transforms/test.js",
"redirects-test": "node tests/deployment/unit/test",
"firebase-utils-test": "node tools/firebase-test-utils/test",
"tools-lint": "tslint --config \"tools/tslint.json\" --project \"tools/firebase-test-utils\" && eslint tools/ng-packages-installer",
"tools-lint": "eslint tools/firebase-test-utils && eslint tools/ng-packages-installer",
"tools-test": "yarn docs-test && yarn boilerplate:test && jasmine tools/ng-packages-installer/index.spec.js && jasmine scripts/deploy-to-firebase.spec.js && yarn firebase-utils-test",
"preserve-and-sync": "yarn docs",
"serve-and-sync": "run-p \"docs-watch --watch-only\" \"start {@}\" --",
Expand Down
23 changes: 23 additions & 0 deletions aio/tools/firebase-test-utils/.eslintrc.json
@@ -0,0 +1,23 @@
{
"extends": "../../.eslintrc.json",
"overrides": [
{
"files": ["*.js"],
"env": {
"es6": true,
"node": true
},
"extends": [
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"quotes": ["error", "single"],
"semi": ["error", "always"],
"no-var": ["error"]
}
}
]
}
9 changes: 4 additions & 5 deletions aio/tools/firebase-test-utils/FirebaseRedirect.ts
Expand Up @@ -7,11 +7,10 @@ export class FirebaseRedirect {
destination: string;

constructor(readonly rawConfig: FirebaseRedirectConfig) {
const {source, regex, destination} = rawConfig;
this.source = (typeof source === 'string') ?
FirebaseRedirectSource.fromGlobPattern(source) :
FirebaseRedirectSource.fromRegexPattern(regex!);
this.destination = destination;
this.source = (rawConfig.regex === undefined) ?
FirebaseRedirectSource.fromGlobPattern(rawConfig.source) :
FirebaseRedirectSource.fromRegexPattern(rawConfig.regex);
this.destination = rawConfig.destination;
}

replace(url: string): string | undefined {
Expand Down
6 changes: 3 additions & 3 deletions aio/tools/firebase-test-utils/FirebaseRedirectSource.spec.ts
Expand Up @@ -344,21 +344,21 @@ function testSource(source: FirebaseRedirectSource, matches: string[], nonMatche
function testGlobMatch(
pattern: string,
captures: { named?: string[], rest?: string[] },
matches: { [url: string]: object|undefined }) {
matches: { [url: string]: unknown|undefined }) {
return testSourceMatch(FirebaseRedirectSource.fromGlobPattern(pattern), captures, matches);
}

function testRegexMatch(
pattern: string,
captures: { named?: string[], rest?: string[] },
matches: { [url: string]: object|undefined }) {
matches: { [url: string]: unknown|undefined }) {
return testSourceMatch(FirebaseRedirectSource.fromRegexPattern(pattern), captures, matches);
}

function testSourceMatch(
source: FirebaseRedirectSource,
captures: { named?: string[], rest?: string[] },
matches: { [url: string]: object|undefined }) {
matches: { [url: string]: unknown|undefined }) {
expect(source.namedGroups).toEqual(captures.named || []);
expect(source.restNamedGroups).toEqual(captures.rest || []);
Object.keys(matches).forEach(url => expect(source.match(url)).toEqual(matches[url]));
Expand Down
3 changes: 2 additions & 1 deletion aio/tools/firebase-test-utils/FirebaseRedirectSource.ts
Expand Up @@ -40,7 +40,7 @@ export class FirebaseRedirectSource {
restNamedGroups.push(groupName);
return `(?:${leadingSlash}(?<${groupName}>.🐷))?`;
})
.replace(namedParam, `$1(?<$2>[^/]+)`)
.replace(namedParam, '$1(?<$2>[^/]+)')
.replace(doubleStar, '$1.🐷$2') // use the pig to avoid replacing ** in next rule
.replace(star, '[^/]*') // match a single segment
.replace(possiblyEmptyInitialSegments, '(?:.*)')// deal with **/ special cases
Expand Down Expand Up @@ -89,6 +89,7 @@ export class FirebaseRedirectSource {

const result: { [key: string]: string } = {};
const names = this.regex.xregexp.captureNames || [];
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
names.forEach(name => result[name] = match.groups![name]);
return result;
}
Expand Down
87 changes: 0 additions & 87 deletions aio/tools/tslint.json

This file was deleted.

0 comments on commit 55d11a8

Please sign in to comment.