Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1262851
webhint.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
webhint.ts
View Options
import
_locreq
from
"locreq"
;
import
{
module_dirname
}
from
"../utils/module_dirname.js"
;
const
locreq
=
_locreq
(
module_dirname
(
import
.
meta
.
url
));
import
{
spawn
}
from
"child_process"
;
import
{
hasShape
,
is
,
predicates
}
from
"@sealcode/ts-predicates"
;
import
{
promises
as
fs
}
from
"fs"
;
export
const
LONG_TEST_TIMEOUT
=
100
*
1000
;
export
const
VERY_LONG_TEST_TIMEOUT
=
75
*
1000
;
export
async
function
webhintURL
(
url
:
string
,
config
=
locreq
.
resolve
(
".hintrc"
))
{
// eslint-disable-next-line no-console
console
.
log
(
"scanning with webhint...."
,
url
);
try
{
const
subprocess
=
spawn
(
"node"
,
[
locreq
.
resolve
(
"webhint/node_modules/.bin/hint"
),
"--config"
,
config
,
url
],
{
cwd
:
locreq
.
resolve
(
"webhint"
)
}
// to prevent webhint from trying to parese source code
);
subprocess
.
stderr
.
on
(
"data"
,
(
b
)
=>
console
.
error
(
String
(
b
)));
// eslint-disable-next-line no-console
subprocess
.
stdout
.
on
(
"data"
,
(
b
)
=>
console
.
log
(
String
(
b
)));
await
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
subprocess
.
on
(
"close"
,
(
code
)
=>
code
===
0
?
resolve
()
:
reject
(
new
Error
(
"Webhint tests failed"
))
);
});
}
catch
(
e
)
{
if
(
is
(
e
,
predicates
.
object
)
&&
hasShape
({
stdout
:
predicates
.
string
},
e
))
{
throw
new
Error
(
e
.
stdout
);
}
else
{
throw
e
;
}
}
}
export
async
function
webhintHTML
(
html
:
string
)
{
await
fs
.
writeFile
(
"/tmp/index.html"
,
html
);
await
webhintURL
(
"/tmp/index.html"
,
locreq
.
resolve
(
".hintrc.local.json"
));
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 24, 15:16 (20 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
599860
Default Alt Text
webhint.ts (1 KB)
Attached To
Mode
rREWRITE Configurable rewriter
Attached
Detach File
Event Timeline
Log In to Comment