Struct Context

Source
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>

Source

pub fn specifier(&self) -> &ModuleSpecifier

File specifier on which the lint rule is run.

Source

pub fn media_type(&self) -> MediaType

The media type which linter was configured with. Can be used to skip checking some rules.

Source

pub fn comments(&self) -> &MultiThreadedComments

Comment collection.

Source

pub fn diagnostics(&self) -> &[LintDiagnostic]

Stores diagnostics that are generated while linting

Source

pub fn parsed_source(&self) -> &ParsedSource

Parsed source of the program.

Source

pub fn text_info(&self) -> &SourceTextInfo

Information about the file text.

Source

pub fn program(&self) -> Program<'a>

The AST view of the program, which for example can be used for getting comments

Source

pub fn file_ignore_directive(&self) -> Option<&IgnoreDirective<File>>

File-level ignore directive (deno-lint-ignore-file)

Source

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.

Source

pub fn scope(&self) -> &Scope

Scope analysis result

Source

pub fn control_flow(&self) -> &ControlFlow

Control-flow analysis result

Source

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.

Source

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.

Source

pub fn all_comments(&self) -> impl Iterator<Item = &'a Comment>

Source

pub fn leading_comments_at( &self, start: SourcePos, ) -> impl Iterator<Item = &'a Comment>

Source

pub fn trailing_comments_at( &self, end: SourcePos, ) -> impl Iterator<Item = &'a Comment>

Source

pub fn add_diagnostic( &mut self, range: SourceRange, code: impl ToString, message: impl ToString, )

Source

pub fn add_diagnostic_with_hint( &mut self, range: SourceRange, code: impl ToString, message: impl ToString, hint: impl ToString, )

Source

pub fn add_diagnostic_with_fixes( &mut self, range: SourceRange, code: impl ToString, message: impl ToString, hint: Option<String>, fixes: Vec<LintFix>, )

Source

pub fn add_diagnostic_details( &mut self, maybe_range: Option<LintDiagnosticRange>, details: LintDiagnosticDetails, )

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Send for T
where T: ?Sized,

Source§

impl<T> Sync for T
where T: ?Sized,