Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
83cc0cb7
Commit
83cc0cb7
authored
Jun 25, 2020
by
aniket-engg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remix-astwalker linting done
parent
dafbe6f1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
56 deletions
+56
-56
.eslintrc
libs/remix-astwalker/.eslintrc
+7
-0
astWalker.ts
libs/remix-astwalker/src/astWalker.ts
+17
-15
sourceMappings.ts
libs/remix-astwalker/src/sourceMappings.ts
+6
-5
types.ts
libs/remix-astwalker/src/types.ts
+2
-2
tsconfig.json
libs/remix-astwalker/tsconfig.json
+4
-28
tsconfig.lib.json
libs/remix-astwalker/tsconfig.lib.json
+14
-0
workspace.json
workspace.json
+6
-6
No files found.
libs/remix-astwalker/.eslintrc
0 → 100644
View file @
83cc0cb7
{
"extends": "../../.eslintrc",
"rules": {
"@typescript-eslint/no-explicit-any": "off"
},
"ignorePatterns": ["!**/*"]
}
libs/remix-astwalker/src/astWalker.ts
View file @
83cc0cb7
...
@@ -9,7 +9,7 @@ const isObject = function(obj: any): boolean {
...
@@ -9,7 +9,7 @@ const isObject = function(obj: any): boolean {
return
obj
!=
null
&&
obj
.
constructor
.
name
===
"Object"
return
obj
!=
null
&&
obj
.
constructor
.
name
===
"Object"
}
}
export
function
isAstNode
(
node
:
Object
):
boolean
{
export
function
isAstNode
(
node
:
Record
<
string
,
unknown
>
):
boolean
{
return
(
return
(
isObject
(
node
)
&&
isObject
(
node
)
&&
'id'
in
node
&&
'id'
in
node
&&
...
@@ -35,7 +35,7 @@ export function isAstNode(node: Object): boolean {
...
@@ -35,7 +35,7 @@ export function isAstNode(node: Object): boolean {
export
class
AstWalker
extends
EventEmitter
{
export
class
AstWalker
extends
EventEmitter
{
manageCallback
(
manageCallback
(
node
:
AstNodeLegacy
|
AstNode
,
node
:
AstNodeLegacy
|
AstNode
,
callback
:
Object
|
Function
callback
:
Record
<
string
,
unknown
>
|
Function
// eslint-disable-line @typescript-eslint/ban-types
):
any
{
):
any
{
// FIXME: we shouldn't be doing this callback determination type on each AST node,
// FIXME: we shouldn't be doing this callback determination type on each AST node,
// since the callback function is set once per walk.
// since the callback function is set once per walk.
...
@@ -58,7 +58,8 @@ export class AstWalker extends EventEmitter {
...
@@ -58,7 +58,8 @@ export class AstWalker extends EventEmitter {
}
}
}
}
}
}
walk
(
ast
:
AstNodeLegacy
|
AstNode
,
callback
?:
Function
|
Object
)
{
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
walk
(
ast
:
AstNodeLegacy
|
AstNode
,
callback
?:
Function
|
Record
<
string
,
unknown
>
)
{
if
(
callback
)
{
if
(
callback
)
{
if
(
callback
instanceof
Function
)
{
if
(
callback
instanceof
Function
)
{
callback
=
Object
({
"*"
:
callback
});
callback
=
Object
({
"*"
:
callback
});
...
@@ -74,8 +75,8 @@ export class AstWalker extends EventEmitter {
...
@@ -74,8 +75,8 @@ export class AstWalker extends EventEmitter {
(
<
AstNodeLegacy
>
ast
).
children
&&
(
<
AstNodeLegacy
>
ast
).
children
&&
(
<
AstNodeLegacy
>
ast
).
children
.
length
>
0
(
<
AstNodeLegacy
>
ast
).
children
.
length
>
0
)
{
)
{
for
(
le
t
k
in
(
<
AstNodeLegacy
>
ast
).
children
)
{
for
(
cons
t
k
in
(
<
AstNodeLegacy
>
ast
).
children
)
{
le
t
child
=
(
<
AstNodeLegacy
>
ast
).
children
[
k
];
cons
t
child
=
(
<
AstNodeLegacy
>
ast
).
children
[
k
];
this
.
walk
(
child
,
callback
);
this
.
walk
(
child
,
callback
);
}
}
}
}
...
@@ -85,8 +86,8 @@ export class AstWalker extends EventEmitter {
...
@@ -85,8 +86,8 @@ export class AstWalker extends EventEmitter {
(
<
AstNode
>
ast
).
nodes
&&
(
<
AstNode
>
ast
).
nodes
&&
(
<
AstNode
>
ast
).
nodes
.
length
>
0
(
<
AstNode
>
ast
).
nodes
.
length
>
0
)
{
)
{
for
(
le
t
k
in
(
<
AstNode
>
ast
).
nodes
)
{
for
(
cons
t
k
in
(
<
AstNode
>
ast
).
nodes
)
{
le
t
child
=
(
<
AstNode
>
ast
).
nodes
[
k
];
cons
t
child
=
(
<
AstNode
>
ast
).
nodes
[
k
];
this
.
walk
(
child
,
callback
);
this
.
walk
(
child
,
callback
);
}
}
}
}
...
@@ -97,8 +98,8 @@ export class AstWalker extends EventEmitter {
...
@@ -97,8 +98,8 @@ export class AstWalker extends EventEmitter {
(
<
AstNodeLegacy
>
ast
).
children
&&
(
<
AstNodeLegacy
>
ast
).
children
&&
(
<
AstNodeLegacy
>
ast
).
children
.
length
>
0
(
<
AstNodeLegacy
>
ast
).
children
.
length
>
0
)
{
)
{
for
(
le
t
k
in
(
<
AstNodeLegacy
>
ast
).
children
)
{
for
(
cons
t
k
in
(
<
AstNodeLegacy
>
ast
).
children
)
{
le
t
child
=
(
<
AstNodeLegacy
>
ast
).
children
[
k
];
cons
t
child
=
(
<
AstNodeLegacy
>
ast
).
children
[
k
];
this
.
emit
(
"node"
,
child
);
this
.
emit
(
"node"
,
child
);
this
.
walk
(
child
);
this
.
walk
(
child
);
}
}
...
@@ -106,8 +107,8 @@ export class AstWalker extends EventEmitter {
...
@@ -106,8 +107,8 @@ export class AstWalker extends EventEmitter {
}
}
if
(
<
AstNode
>
ast
)
{
if
(
<
AstNode
>
ast
)
{
if
((
<
AstNode
>
ast
).
nodes
&&
(
<
AstNode
>
ast
).
nodes
.
length
>
0
)
{
if
((
<
AstNode
>
ast
).
nodes
&&
(
<
AstNode
>
ast
).
nodes
.
length
>
0
)
{
for
(
le
t
k
in
(
<
AstNode
>
ast
).
nodes
)
{
for
(
cons
t
k
in
(
<
AstNode
>
ast
).
nodes
)
{
le
t
child
=
(
<
AstNode
>
ast
).
nodes
[
k
];
cons
t
child
=
(
<
AstNode
>
ast
).
nodes
[
k
];
this
.
emit
(
"node"
,
child
);
this
.
emit
(
"node"
,
child
);
this
.
walk
(
child
);
this
.
walk
(
child
);
}
}
...
@@ -115,18 +116,18 @@ export class AstWalker extends EventEmitter {
...
@@ -115,18 +116,18 @@ export class AstWalker extends EventEmitter {
}
}
}
}
}
}
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
walkFullInternal
(
ast
:
AstNode
,
callback
:
Function
)
{
walkFullInternal
(
ast
:
AstNode
,
callback
:
Function
)
{
if
(
isAstNode
(
ast
))
{
if
(
isAstNode
(
ast
))
{
// console.log(`XXX id ${ast.id}, nodeType: ${ast.nodeType}, src: ${ast.src}`);
// console.log(`XXX id ${ast.id}, nodeType: ${ast.nodeType}, src: ${ast.src}`);
callback
(
ast
);
callback
(
ast
);
for
(
le
t
k
of
Object
.
keys
(
ast
))
{
for
(
cons
t
k
of
Object
.
keys
(
ast
))
{
// Possible optimization:
// Possible optimization:
// if (k in ['id', 'src', 'nodeType']) continue;
// if (k in ['id', 'src', 'nodeType']) continue;
const
astItem
=
ast
[
k
];
const
astItem
=
ast
[
k
];
if
(
Array
.
isArray
(
astItem
))
{
if
(
Array
.
isArray
(
astItem
))
{
for
(
le
t
child
of
astItem
)
{
for
(
cons
t
child
of
astItem
)
{
if
(
child
)
{
if
(
child
)
{
this
.
walkFullInternal
(
child
,
callback
);
this
.
walkFullInternal
(
child
,
callback
);
}
}
...
@@ -139,12 +140,13 @@ export class AstWalker extends EventEmitter {
...
@@ -139,12 +140,13 @@ export class AstWalker extends EventEmitter {
}
}
// Normalizes parameter callback and calls walkFullInternal
// Normalizes parameter callback and calls walkFullInternal
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
walkFull
(
ast
:
AstNode
,
callback
:
any
)
{
walkFull
(
ast
:
AstNode
,
callback
:
any
)
{
if
(
!
isAstNode
(
ast
))
throw
new
TypeError
(
"first argument should be an ast"
);
if
(
!
isAstNode
(
ast
))
throw
new
TypeError
(
"first argument should be an ast"
);
return
this
.
walkFullInternal
(
ast
,
callback
);
return
this
.
walkFullInternal
(
ast
,
callback
);
}
}
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/explicit-module-boundary-types
walkAstList
(
sourcesList
:
Node
,
cb
?:
Function
)
{
walkAstList
(
sourcesList
:
Node
,
cb
?:
Function
)
{
if
(
cb
)
{
if
(
cb
)
{
if
(
sourcesList
.
ast
)
{
if
(
sourcesList
.
ast
)
{
...
...
libs/remix-astwalker/src/sourceMappings.ts
View file @
83cc0cb7
...
@@ -3,6 +3,7 @@ import { AstNode, LineColPosition, LineColRange, Location } from "./types";
...
@@ -3,6 +3,7 @@ import { AstNode, LineColPosition, LineColRange, Location } from "./types";
import
{
util
}
from
"remix-lib"
;
import
{
util
}
from
"remix-lib"
;
export
declare
interface
SourceMappings
{
export
declare
interface
SourceMappings
{
// eslint-disable-next-line @typescript-eslint/no-misused-new
new
():
SourceMappings
;
new
():
SourceMappings
;
}
}
...
@@ -67,8 +68,8 @@ export class SourceMappings {
...
@@ -67,8 +68,8 @@ export class SourceMappings {
// Create a list of line offsets which will be used to map between
// Create a list of line offsets which will be used to map between
// character offset and line/column positions.
// character offset and line/column positions.
le
t
lineBreaks
:
Array
<
number
>
=
[];
cons
t
lineBreaks
:
Array
<
number
>
=
[];
for
(
var
pos
=
source
.
indexOf
(
'
\
n'
);
pos
>=
0
;
pos
=
source
.
indexOf
(
'
\
n'
,
pos
+
1
))
{
for
(
let
pos
=
source
.
indexOf
(
'
\
n'
);
pos
>=
0
;
pos
=
source
.
indexOf
(
'
\
n'
,
pos
+
1
))
{
lineBreaks
.
push
(
pos
)
lineBreaks
.
push
(
pos
)
}
}
this
.
lineBreaks
=
lineBreaks
;
this
.
lineBreaks
=
lineBreaks
;
...
@@ -82,10 +83,10 @@ export class SourceMappings {
...
@@ -82,10 +83,10 @@ export class SourceMappings {
*/
*/
nodesAtPosition
(
astNodeType
:
string
|
null
,
position
:
Location
,
ast
:
AstNode
):
Array
<
AstNode
>
{
nodesAtPosition
(
astNodeType
:
string
|
null
,
position
:
Location
,
ast
:
AstNode
):
Array
<
AstNode
>
{
const
astWalker
=
new
AstWalker
()
const
astWalker
=
new
AstWalker
()
le
t
found
:
Array
<
AstNode
>
=
[];
cons
t
found
:
Array
<
AstNode
>
=
[];
const
callback
=
function
(
node
:
AstNode
):
boolean
{
const
callback
=
function
(
node
:
AstNode
):
boolean
{
le
t
nodeLocation
=
sourceLocationFromAstNode
(
node
);
cons
t
nodeLocation
=
sourceLocationFromAstNode
(
node
);
if
(
nodeLocation
&&
if
(
nodeLocation
&&
nodeLocation
.
start
==
position
.
start
&&
nodeLocation
.
start
==
position
.
start
&&
nodeLocation
.
length
==
position
.
length
)
{
nodeLocation
.
length
==
position
.
length
)
{
...
@@ -111,7 +112,7 @@ export class SourceMappings {
...
@@ -111,7 +112,7 @@ export class SourceMappings {
/* FIXME: Looking at AST walker code,
/* FIXME: Looking at AST walker code,
I don't understand a need to return a boolean. */
I don't understand a need to return a boolean. */
const
callback
=
function
(
node
:
AstNode
)
{
const
callback
=
function
(
node
:
AstNode
)
{
le
t
nodeLocation
=
sourceLocationFromAstNode
(
node
);
cons
t
nodeLocation
=
sourceLocationFromAstNode
(
node
);
if
(
nodeLocation
&&
if
(
nodeLocation
&&
nodeLocation
.
start
==
sourceLocation
.
start
&&
nodeLocation
.
start
==
sourceLocation
.
start
&&
nodeLocation
.
length
==
sourceLocation
.
length
)
{
nodeLocation
.
length
==
sourceLocation
.
length
)
{
...
...
libs/remix-astwalker/src/types.ts
View file @
83cc0cb7
...
@@ -37,7 +37,7 @@ export interface AstNode {
...
@@ -37,7 +37,7 @@ export interface AstNode {
src
:
string
;
src
:
string
;
absolutePath
?:
string
;
absolutePath
?:
string
;
exportedSymbols
?:
Object
;
exportedSymbols
?:
Record
<
string
,
unknown
>
;
nodes
?:
Array
<
AstNode
>
;
nodes
?:
Array
<
AstNode
>
;
literals
?:
Array
<
string
>
;
literals
?:
Array
<
string
>
;
file
?:
string
;
file
?:
string
;
...
@@ -63,7 +63,7 @@ export interface AstNodeAtt {
...
@@ -63,7 +63,7 @@ export interface AstNodeAtt {
constant
?:
boolean
;
constant
?:
boolean
;
name
?:
string
;
name
?:
string
;
public
?:
boolean
;
public
?:
boolean
;
exportedSymbols
?:
Object
;
exportedSymbols
?:
Record
<
string
,
unknown
>
;
argumentTypes
?:
null
;
argumentTypes
?:
null
;
absolutePath
?:
string
;
absolutePath
?:
string
;
[
x
:
string
]:
any
;
[
x
:
string
]:
any
;
...
...
libs/remix-astwalker/tsconfig.json
View file @
83cc0cb7
{
{
"include"
:
[
"src"
],
"extends"
:
"../../tsconfig.json"
,
"exclude"
:
[
"node_modules"
,
"src/@types"
],
"compilerOptions"
:
{
"compilerOptions"
:
{
/*
Basic
Options
*/
"types"
:
[
"node"
],
"target"
:
"es5"
,
/*
Specify
ECMAScript
target
version
:
'ES
3
'
(default)
,
'ES
5
'
,
'ES
2015
'
,
'ES
2016
'
,
'ES
2017
'
,
'ES
2018
'
or
'ESNEXT'.
*/
},
"module"
:
"commonjs"
,
/*
Specify
module
code
generation
:
'none'
,
'commonjs'
,
'amd'
,
'system'
,
'umd'
,
'es
2015
'
,
or
'ESNext'.
*/
"include"
:
[
"**/*.ts"
]
"lib"
:
[
"dom"
,
"es2018"
],
/*
Specify
library
files
to
be
included
in
the
compilation.
*/
"declaration"
:
true
,
/*
Generates
corresponding
'.d.ts'
file.
*/
"sourceMap"
:
true
,
/*
Generates
corresponding
'.map'
file.
*/
"outDir"
:
"./dist"
,
/*
Redirect
output
structure
to
the
directory.
*/
/*
Strict
Type-Checking
Options
*/
"strict"
:
true
,
/*
Enable
all
strict
type-checking
options.
*/
"noImplicitAny"
:
false
,
/*
Raise
error
on
expressions
and
declarations
with
an
implied
'any'
type.
*/
/*
Module
Resolution
Options
*/
"baseUrl"
:
"./src"
,
/*
Base
directory
to
resolve
non-absolute
module
names.
*/
"paths"
:
{
"remix-tests"
:
[
"./"
]
},
/*
A
series
of
entries
which
re-map
imports
to
lookup
locations
relative
to
the
'baseUrl'.
*/
"typeRoots"
:
[
"./@types"
,
"node_modules/@types"
],
/*
List
of
folders
to
include
type
definitions
from.
*/
"esModuleInterop"
:
true
,
/*
Enables
emit
interoperability
between
CommonJS
and
ES
Modules
via
creation
of
namespace
objects
for
all
imports.
Implies
'allowSyntheticDefaultImports'.
*/
"types"
:
[
"node"
],
/*
Experimental
Options
*/
"experimentalDecorators"
:
true
,
/*
Enables
experimental
support
for
ES
7
decorators.
*/
"allowSyntheticDefaultImports"
:
true
,
//
Disables
strictNullChecks
"strictNullChecks"
:
false
}
}
}
libs/remix-astwalker/tsconfig.lib.json
0 → 100644
View file @
83cc0cb7
{
"extends"
:
"./tsconfig.json"
,
"compilerOptions"
:
{
"module"
:
"commonjs"
,
"outDir"
:
"../../dist/out-tsc"
,
"declaration"
:
true
,
"rootDir"
:
"./src"
,
"types"
:
[
"node"
]
},
"exclude"
:
[
"**/*.spec.ts"
],
"include"
:
[
"**/*.ts"
]
}
\ No newline at end of file
workspace.json
View file @
83cc0cb7
...
@@ -117,14 +117,14 @@
...
@@ -117,14 +117,14 @@
"schematics"
:
{},
"schematics"
:
{},
"architect"
:
{
"architect"
:
{
"lint"
:
{
"lint"
:
{
"builder"
:
"@nrwl/
workspace:run-commands
"
,
"builder"
:
"@nrwl/
linter:lint
"
,
"options"
:
{
"options"
:
{
"
commands"
:
[
"
linter"
:
"eslint"
,
{
"config"
:
"libs/remix-astwalker/.eslintrc"
,
"command"
:
"./../../node_modules/.bin/npm-run-all lint"
"tsConfig"
:
[
}
"libs/remix-astwalker/tsconfig.lib.json"
],
],
"
cwd"
:
"libs/remix-astwalker"
"
exclude"
:
[
"**/node_modules/**"
,
"libs/remix-astwalker/tests/**/*"
]
}
}
},
},
"test"
:
{
"test"
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment