mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 01:38:07 +08:00
This reverts commit2b4a9df2d9. Reason for revert: subsequent presubmit uploads should be fixed now. Original change's description: > Revert "Reland "Update stylelint to 14.0.1"" > > This reverts commitf2ea2c940d. > > Reason for revert: https://ci.chromium.org/ui/p/devtools-frontend/builders/try/dtf_presubmit_linux/b8831129368825517985/overview > > Original change's description: > > Reland "Update stylelint to 14.0.1" > > > > This reverts commit6c0f161c95. > > > > Reason for revert: the prerequisite CL (https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3259703) has landed > > > > Original change's description: > > > Revert "Update stylelint to 14.0.1" > > > > > > This reverts commit1e08ee816b. > > > > > > Reason for revert: tree is closed due to errors https://ci.chromium.org/ui/p/devtools-frontend/builders/ci/Stand-alone%20Linux/8169/overview > > > > > > Original change's description: > > > > Update stylelint to 14.0.1 > > > > > > > > This also upgrades PostCSS to 8.3.11. > > > > > > > > DISABLE_THIRD_PARTY_CHECK=Updating Stylelint configuration > > > > R=szuend@chromium.org > > > > > > > > Bug: none > > > > Change-Id: I606540b03509d7c6e73f3d490327cd4174e03d31 > > > > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3259541 > > > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > > > Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> > > > > > > Bug: none > > > Change-Id: Icb1c02b41dbccc3b4fc5760f5dd0b78eca078b61 > > > No-Presubmit: true > > > No-Tree-Checks: true > > > No-Try: true > > > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3263399 > > > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > > > Owners-Override: Alex Rudenko <alexrudenko@chromium.org> > > > Commit-Queue: Alex Rudenko <alexrudenko@chromium.org> > > > > DISABLE_THIRD_PARTY_CHECK=Updating Stylelint configuration > > > > Bug: none > > Change-Id: If132a67ee4253d27114caedd66c5ee61c774a6c7 > > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3264206 > > Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> > > Bug: none > Change-Id: Idc6c9f5cc1e225c752799461eb0344e94b4ad1e5 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3264222 > Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org> > Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> DISABLE_THIRD_PARTY_CHECK=Updating Stylelint configuration Bug: none Change-Id: I609941d48b46bfcf454b03dcc75a76d460fbe674 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3264223 Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
193 lines
4.7 KiB
TypeScript
193 lines
4.7 KiB
TypeScript
import { FilePosition } from './input.js'
|
|
|
|
/**
|
|
* The CSS parser throws this error for broken CSS.
|
|
*
|
|
* Custom parsers can throw this error for broken custom syntax using
|
|
* the `Node#error` method.
|
|
*
|
|
* PostCSS will use the input source map to detect the original error location.
|
|
* If you wrote a Sass file, compiled it to CSS and then parsed it with PostCSS,
|
|
* PostCSS will show the original position in the Sass file.
|
|
*
|
|
* If you need the position in the PostCSS input
|
|
* (e.g., to debug the previous compiler), use `error.input.file`.
|
|
*
|
|
* ```js
|
|
* // Raising error from plugin
|
|
* throw node.error('Unknown variable', { plugin: 'postcss-vars' })
|
|
* ```
|
|
*
|
|
* ```js
|
|
* // Catching and checking syntax error
|
|
* try {
|
|
* postcss.parse('a{')
|
|
* } catch (error) {
|
|
* if (error.name === 'CssSyntaxError') {
|
|
* error //=> CssSyntaxError
|
|
* }
|
|
* }
|
|
* ```
|
|
*/
|
|
export default class CssSyntaxError {
|
|
/**
|
|
* @param message Error message.
|
|
* @param line Source line of the error.
|
|
* @param column Source column of the error.
|
|
* @param source Source code of the broken file.
|
|
* @param file Absolute path to the broken file.
|
|
* @param plugin PostCSS plugin name, if error came from plugin.
|
|
*/
|
|
constructor(
|
|
message: string,
|
|
line?: number,
|
|
column?: number,
|
|
source?: string,
|
|
file?: string,
|
|
plugin?: string
|
|
)
|
|
|
|
stack: string
|
|
|
|
/**
|
|
* Always equal to `'CssSyntaxError'`. You should always check error type
|
|
* by `error.name === 'CssSyntaxError'`
|
|
* instead of `error instanceof CssSyntaxError`,
|
|
* because npm could have several PostCSS versions.
|
|
*
|
|
* ```js
|
|
* if (error.name === 'CssSyntaxError') {
|
|
* error //=> CssSyntaxError
|
|
* }
|
|
* ```
|
|
*/
|
|
name: 'CssSyntaxError'
|
|
|
|
/**
|
|
* Error message.
|
|
*
|
|
* ```js
|
|
* error.message //=> 'Unclosed block'
|
|
* ```
|
|
*/
|
|
reason: string
|
|
|
|
/**
|
|
* Full error text in the GNU error format
|
|
* with plugin, file, line and column.
|
|
*
|
|
* ```js
|
|
* error.message //=> 'a.css:1:1: Unclosed block'
|
|
* ```
|
|
*/
|
|
message: string
|
|
|
|
/**
|
|
* Absolute path to the broken file.
|
|
*
|
|
* ```js
|
|
* error.file //=> 'a.sass'
|
|
* error.input.file //=> 'a.css'
|
|
* ```
|
|
*
|
|
* PostCSS will use the input source map to detect the original location.
|
|
* If you need the position in the PostCSS input, use `error.input.file`.
|
|
*/
|
|
file?: string
|
|
|
|
/**
|
|
* Source line of the error.
|
|
*
|
|
* ```js
|
|
* error.line //=> 2
|
|
* error.input.line //=> 4
|
|
* ```
|
|
*
|
|
* PostCSS will use the input source map to detect the original location.
|
|
* If you need the position in the PostCSS input, use `error.input.line`.
|
|
*/
|
|
line?: number
|
|
|
|
/**
|
|
* Source column of the error.
|
|
*
|
|
* ```js
|
|
* error.column //=> 1
|
|
* error.input.column //=> 4
|
|
* ```
|
|
*
|
|
* PostCSS will use the input source map to detect the original location.
|
|
* If you need the position in the PostCSS input, use `error.input.column`.
|
|
*/
|
|
column?: number
|
|
|
|
/**
|
|
* Source code of the broken file.
|
|
*
|
|
* ```js
|
|
* error.source //=> 'a { b {} }'
|
|
* error.input.source //=> 'a b { }'
|
|
* ```
|
|
*/
|
|
source?: string
|
|
|
|
/**
|
|
* Plugin name, if error came from plugin.
|
|
*
|
|
* ```js
|
|
* error.plugin //=> 'postcss-vars'
|
|
* ```
|
|
*/
|
|
plugin?: string
|
|
|
|
/**
|
|
* Input object with PostCSS internal information
|
|
* about input file. If input has source map
|
|
* from previous tool, PostCSS will use origin
|
|
* (for example, Sass) source. You can use this
|
|
* object to get PostCSS input source.
|
|
*
|
|
* ```js
|
|
* error.input.file //=> 'a.css'
|
|
* error.file //=> 'a.sass'
|
|
* ```
|
|
*/
|
|
input?: FilePosition
|
|
|
|
/**
|
|
* Returns error position, message and source code of the broken part.
|
|
*
|
|
* ```js
|
|
* error.toString() //=> "CssSyntaxError: app.css:1:1: Unclosed block
|
|
* // > 1 | a {
|
|
* // | ^"
|
|
* ```
|
|
*
|
|
* @return Error position, message and source code.
|
|
*/
|
|
toString(): string
|
|
|
|
/**
|
|
* Returns a few lines of CSS source that caused the error.
|
|
*
|
|
* If the CSS has an input source map without `sourceContent`,
|
|
* this method will return an empty string.
|
|
*
|
|
* ```js
|
|
* error.showSourceCode() //=> " 4 | }
|
|
* // 5 | a {
|
|
* // > 6 | bad
|
|
* // | ^
|
|
* // 7 | }
|
|
* // 8 | b {"
|
|
* ```
|
|
*
|
|
* @param color Whether arrow will be colored red by terminal
|
|
* color codes. By default, PostCSS will detect
|
|
* color support by `process.stdout.isTTY`
|
|
* and `process.env.NODE_DISABLE_COLORS`.
|
|
* @return Few lines of CSS source that caused the error.
|
|
*/
|
|
showSourceCode(color?: boolean): string
|
|
}
|