Skip to content

Commit ae6672f

Browse files
author
David Tanner
committed
chore: use nearley preprocessor to get typescript
1 parent 6b119c0 commit ae6672f

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"ignorePatterns": [
1111
"/lib/",
12-
"src/utils/lambdaURLGrammar.js"
12+
"src/utils/lambdaURLGrammar.ts"
1313
],
1414
"rules": {
1515
"@typescript-eslint/restrict-template-expressions": "off"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ node_modules/
88
/src/**/*.d.ts
99
.idea
1010
yarn-error.log
11+
src/utils/lambdaURLGrammar.ts

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"url": "https://github.com/lifeomic/alpha.git"
1919
},
2020
"scripts": {
21-
"buildGrammar": "nearleyc src/utils/lambdaURL.ne -o src/utils/lambdaURLGrammar.js",
21+
"buildGrammar": "nearleyc src/utils/lambdaURL.ne -o src/utils/lambdaURLGrammar.ts",
2222
"lint": "eslint .",
2323
"postlint": "yarn tsc",
2424
"lint:fix": "eslint --fix .",

src/utils/lambdaURL.ne

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@preprocessor typescript
2+
13
@{%
24
const flattenDeep = require('lodash/flattenDeep');
35
const get = require('lodash/get');

src/utils/url.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import nearley, { CompiledRules } from 'nearley';
1+
import nearley from 'nearley';
2+
import grammar from './lambdaURLGrammar';
23

34
const WITH_SCHEME = /^[a-z][a-z\d+\-.]*:\/\//i;
45

56
export const isAbsoluteURL = (url: string) => WITH_SCHEME.test(url) || url.startsWith('//');
67

7-
// eslint-disable-next-line @typescript-eslint/no-require-imports
8-
const grammar = require('./lambdaURLGrammar') as CompiledRules;
9-
108
export const isLambdaUrl = (url: string) => !!url.match(/^lambda:\/\//);
119

1210
export interface LambdaUrl {

0 commit comments

Comments
 (0)