pub struct Context<'view> { /* private fields */ }
Expand description
Context
stores all data needed to perform linting of a particular file.
Implementations§
source§impl<'view> Context<'view>
impl<'view> Context<'view>
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 diagnostics(&self) -> &[LintDiagnostic]
pub fn diagnostics(&self) -> &[LintDiagnostic]
Stores diagnostics that are generated while linting
sourcepub fn text_info(&self) -> &SourceTextInfo
pub fn text_info(&self) -> &SourceTextInfo
Information about the file text.
sourcepub fn program(&self) -> Program<'view>
pub fn program(&self) -> Program<'view>
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<Arc<Box<Expr>>>
pub fn jsx_factory(&self) -> Option<Arc<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<Arc<Box<Expr>>>
pub fn jsx_fragment_factory(&self) -> Option<Arc<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 = &'view Comment>
pub fn leading_comments_at( &self, start: SourcePos ) -> impl Iterator<Item = &'view Comment>
pub fn trailing_comments_at( &self, end: SourcePos ) -> impl Iterator<Item = &'view 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> )
Auto Trait Implementations§
impl<'view> Freeze for Context<'view>
impl<'view> !RefUnwindSafe for Context<'view>
impl<'view> !Send for Context<'view>
impl<'view> !Sync for Context<'view>
impl<'view> Unpin for Context<'view>
impl<'view> !UnwindSafe for Context<'view>
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