Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101488270
css-syntax-error.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 10, 22:51
Size
2 KB
Mime Type
text/x-c++
Expires
Wed, Feb 12, 22:51 (2 d)
Engine
blob
Format
Raw Data
Handle
24156754
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
css-syntax-error.js
View Options
'use strict'
let
pico
=
require
(
'picocolors'
)
let
terminalHighlight
=
require
(
'./terminal-highlight'
)
class
CssSyntaxError
extends
Error
{
constructor
(
message
,
line
,
column
,
source
,
file
,
plugin
)
{
super
(
message
)
this
.
name
=
'CssSyntaxError'
this
.
reason
=
message
if
(
file
)
{
this
.
file
=
file
}
if
(
source
)
{
this
.
source
=
source
}
if
(
plugin
)
{
this
.
plugin
=
plugin
}
if
(
typeof
line
!==
'undefined'
&&
typeof
column
!==
'undefined'
)
{
if
(
typeof
line
===
'number'
)
{
this
.
line
=
line
this
.
column
=
column
}
else
{
this
.
line
=
line
.
line
this
.
column
=
line
.
column
this
.
endLine
=
column
.
line
this
.
endColumn
=
column
.
column
}
}
this
.
setMessage
()
if
(
Error
.
captureStackTrace
)
{
Error
.
captureStackTrace
(
this
,
CssSyntaxError
)
}
}
setMessage
()
{
this
.
message
=
this
.
plugin
?
this
.
plugin
+
': '
:
''
this
.
message
+=
this
.
file
?
this
.
file
:
'<css input>'
if
(
typeof
this
.
line
!==
'undefined'
)
{
this
.
message
+=
':'
+
this
.
line
+
':'
+
this
.
column
}
this
.
message
+=
': '
+
this
.
reason
}
showSourceCode
(
color
)
{
if
(
!
this
.
source
)
return
''
let
css
=
this
.
source
if
(
color
==
null
)
color
=
pico
.
isColorSupported
if
(
terminalHighlight
)
{
if
(
color
)
css
=
terminalHighlight
(
css
)
}
let
lines
=
css
.
split
(
/\r?\n/
)
let
start
=
Math
.
max
(
this
.
line
-
3
,
0
)
let
end
=
Math
.
min
(
this
.
line
+
2
,
lines
.
length
)
let
maxWidth
=
String
(
end
).
length
let
mark
,
aside
if
(
color
)
{
let
{
bold
,
red
,
gray
}
=
pico
.
createColors
(
true
)
mark
=
text
=>
bold
(
red
(
text
))
aside
=
text
=>
gray
(
text
)
}
else
{
mark
=
aside
=
str
=>
str
}
return
lines
.
slice
(
start
,
end
)
.
map
((
line
,
index
)
=>
{
let
number
=
start
+
1
+
index
let
gutter
=
' '
+
(
' '
+
number
).
slice
(
-
maxWidth
)
+
' | '
if
(
number
===
this
.
line
)
{
let
spacing
=
aside
(
gutter
.
replace
(
/\d/g
,
' '
))
+
line
.
slice
(
0
,
this
.
column
-
1
).
replace
(
/[^\t]/g
,
' '
)
return
mark
(
'>'
)
+
aside
(
gutter
)
+
line
+
'\n '
+
spacing
+
mark
(
'^'
)
}
return
' '
+
aside
(
gutter
)
+
line
})
.
join
(
'\n'
)
}
toString
()
{
let
code
=
this
.
showSourceCode
()
if
(
code
)
{
code
=
'\n\n'
+
code
+
'\n'
}
return
this
.
name
+
': '
+
this
.
message
+
code
}
}
module
.
exports
=
CssSyntaxError
CssSyntaxError
.
default
=
CssSyntaxError
Event Timeline
Log In to Comment