pub struct Context<'a> { /* private fields */ }
Expand description
Context
stores all data needed to perform linting of a particular file.
Implementations§
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn specifier(&self) -> &ModuleSpecifier
pub fn specifier(&self) -> &ModuleSpecifier
File specifier on which the lint rule is run.
Sourcepub fn media_type(&self) -> MediaType
pub fn media_type(&self) -> MediaType
The media type which linter was configured with. Can be used to skip checking some rules.
Sourcepub fn comments(&self) -> &MultiThreadedComments
pub fn comments(&self) -> &MultiThreadedComments
Comment collection.
Sourcepub fn diagnostics(&self) -> &[LintDiagnostic]
pub fn diagnostics(&self) -> &[LintDiagnostic]
Stores diagnostics that are generated while linting
Sourcepub fn parsed_source(&self) -> &ParsedSource
pub fn parsed_source(&self) -> &ParsedSource
Parsed source of the program.
Sourcepub fn text_info(&self) -> &SourceTextInfo
pub fn text_info(&self) -> &SourceTextInfo
Information about the file text.
Sourcepub fn program(&self) -> Program<'a>
pub fn program(&self) -> Program<'a>
The AST view of the program, which for example can be used for getting comments
Sourcepub fn file_ignore_directive(&self) -> Option<&IgnoreDirective<File>>
pub fn file_ignore_directive(&self) -> Option<&IgnoreDirective<File>>
File-level ignore directive (deno-lint-ignore-file
)
Sourcepub fn line_ignore_directives(&self) -> &HashMap<usize, IgnoreDirective<Line>>
pub fn line_ignore_directives(&self) -> &HashMap<usize, IgnoreDirective<Line>>
The map that stores line-level ignore directives (deno-lint-ignore
).
The key of the map is line number.
Sourcepub fn control_flow(&self) -> &ControlFlow
pub fn control_flow(&self) -> &ControlFlow
Control-flow analysis result
Sourcepub fn jsx_factory(&self) -> Option<Rc<Box<Expr>>>
pub fn jsx_factory(&self) -> Option<Rc<Box<Expr>>>
Get the JSX factory expression for this file, if one is specified (via
pragma or using a default). If this file is not JSX, uses the automatic
transform, or the default factory is not specified, this will return
None
.
Sourcepub fn jsx_fragment_factory(&self) -> Option<Rc<Box<Expr>>>
pub fn jsx_fragment_factory(&self) -> Option<Rc<Box<Expr>>>
Get the JSX fragment factory expression for this file, if one is specified
(via pragma or using a default). If this file is not JSX, uses the
automatic transform, or the default factory is not specified, this will
return None
.
pub fn all_comments(&self) -> impl Iterator<Item = &'a Comment>
pub fn leading_comments_at( &self, start: SourcePos, ) -> impl Iterator<Item = &'a Comment>
pub fn trailing_comments_at( &self, end: SourcePos, ) -> impl Iterator<Item = &'a Comment>
pub fn add_diagnostic( &mut self, range: SourceRange, code: impl ToString, message: impl ToString, )
pub fn add_diagnostic_with_hint( &mut self, range: SourceRange, code: impl ToString, message: impl ToString, hint: impl ToString, )
pub fn add_diagnostic_with_fixes( &mut self, range: SourceRange, code: impl ToString, message: impl ToString, hint: Option<String>, fixes: Vec<LintFix>, )
pub fn add_diagnostic_details( &mut self, maybe_range: Option<LintDiagnosticRange>, details: LintDiagnosticDetails, )
Sourcepub fn add_external_diagnostics(&mut self, diagnostics: &[LintDiagnostic])
pub fn add_external_diagnostics(&mut self, diagnostics: &[LintDiagnostic])
Add fully constructed diagnostics.
This function can be used by the “external linter” to provide its own diagnostics.
Auto Trait Implementations§
impl<'a> Freeze for Context<'a>
impl<'a> !RefUnwindSafe for Context<'a>
impl<'a> !Send for Context<'a>
impl<'a> !Sync for Context<'a>
impl<'a> Unpin for Context<'a>
impl<'a> !UnwindSafe for Context<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more