Class: SlimLint::Linter Abstract
- Inherits:
-
Object
- Object
- SlimLint::Linter
- Extended by:
- SexpVisitor::DSL
- Includes:
- SexpVisitor
- Defined in:
- lib/slim_lint/linter.rb
Overview
Base implementation for all lint checks.
Defined Under Namespace
Classes: CommentControlStatement, ConsecutiveControlStatements, ControlStatementSpacing, EmbeddedEngines, EmptyControlStatement, EmptyLines, FileLength, InstanceVariables, LineLength, QuoteConsistency, RedundantDiv, RuboCop, StrictLocalsMissing, Tab, Tag, TagAttribute, TagCase, TrailingBlankLines, TrailingWhitespace, Zwsp
Instance Attribute Summary collapse
-
#lints ⇒ Object
readonly
List of lints reported by this linter.
Attributes included from SexpVisitor::DSL
Class Method Summary collapse
-
.support_autocorrect ⇒ Object
Declares that this linter can automatically correct (some of) the offenses it reports.
-
.supports_autocorrect? ⇒ Boolean
Returns whether this linter declared autocorrect support.
Instance Method Summary collapse
-
#initialize(config) ⇒ Linter
constructor
Initializes a linter with the specified configuration.
-
#name ⇒ String
Returns the simple name for this linter.
-
#run(document) ⇒ Object
Runs the linter against the given Slim document.
Methods included from SexpVisitor::DSL
anything, capture, on, on_start
Methods included from SexpVisitor
#captures, #on_start, #patterns, #traverse, #traverse_children, #trigger_pattern_callbacks
Constructor Details
#initialize(config) ⇒ Linter
Initializes a linter with the specified configuration.
36 37 38 39 |
# File 'lib/slim_lint/linter.rb', line 36 def initialize(config) @config = config @lints = [] end |
Instance Attribute Details
#lints ⇒ Object (readonly)
Remove once spec/support/shared_linter_context returns an array of lints for the subject instead of the linter itself.
List of lints reported by this linter.
16 17 18 |
# File 'lib/slim_lint/linter.rb', line 16 def lints @lints end |
Class Method Details
.support_autocorrect ⇒ Object
Declares that this linter can automatically correct (some of) the offenses it reports.
21 22 23 |
# File 'lib/slim_lint/linter.rb', line 21 def support_autocorrect @supports_autocorrect = true end |
.supports_autocorrect? ⇒ Boolean
Returns whether this linter declared autocorrect support.
28 29 30 |
# File 'lib/slim_lint/linter.rb', line 28 def supports_autocorrect? @supports_autocorrect || false end |
Instance Method Details
#name ⇒ String
Returns the simple name for this linter.
55 56 57 |
# File 'lib/slim_lint/linter.rb', line 55 def name self.class.name.split('::').last end |
#run(document) ⇒ Object
Runs the linter against the given Slim document.
44 45 46 47 48 49 50 |
# File 'lib/slim_lint/linter.rb', line 44 def run(document) @document = document @lints = [] @disabled_lines = nil trigger_pattern_callbacks(document.sexp) @lints end |