Class: HamlLint::Linter Abstract
- Inherits:
-
Object
- Object
- HamlLint::Linter
- Includes:
- HamlVisitor
- Defined in:
- lib/haml_lint/linter.rb
Overview
Base implementation for all lint checks.
Direct Known Subclasses
AlignmentTabs, AltText, ClassAttributeWithStaticValue, ClassesBeforeIds, ConsecutiveComments, ConsecutiveSilentScripts, EmptyObjectReference, EmptyScript, FinalNewline, HtmlAttributes, IdNames, ImplicitDiv, Indentation, InstanceVariables, LeadingCommentSpace, LineLength, MultilinePipe, MultilineScript, ObjectReferenceAttributes, RepeatedId, RuboCop, RubyComments, SpaceBeforeScript, SpaceInsideHashAttributes, Syntax, TagName, TrailingWhitespace, UnnecessaryInterpolation, UnnecessaryStringOutput
Defined Under Namespace
Classes: AlignmentTabs, AltText, ClassAttributeWithStaticValue, ClassesBeforeIds, ConsecutiveComments, ConsecutiveSilentScripts, EmptyObjectReference, EmptyScript, FinalNewline, HtmlAttributes, IdNames, ImplicitDiv, Indentation, InstanceVariables, LeadingCommentSpace, LineLength, MultilinePipe, MultilineScript, ObjectReferenceAttributes, RepeatedId, RuboCop, RubyComments, SpaceBeforeScript, SpaceInsideHashAttributes, Syntax, TagName, TrailingWhitespace, UnnecessaryInterpolation, UnnecessaryStringOutput
Instance Attribute Summary collapse
-
#lints ⇒ Object
readonly
List of lints reported by this linter.
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 Haml document.
Methods included from HamlVisitor
Constructor Details
#initialize(config) ⇒ Linter
Initializes a linter with the specified configuration.
17 18 19 20 |
# File 'lib/haml_lint/linter.rb', line 17 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.
12 13 14 |
# File 'lib/haml_lint/linter.rb', line 12 def lints @lints end |
Instance Method Details
#name ⇒ String
Returns the simple name for this linter.
45 46 47 |
# File 'lib/haml_lint/linter.rb', line 45 def name self.class.name.to_s.split('::').last end |
#run(document) ⇒ Object
Runs the linter against the given Haml document.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/haml_lint/linter.rb', line 25 def run(document) @document = document @lints = [] visit(document.tree) @lints rescue Parser::SyntaxError => ex location = ex.diagnostic.location @lints << HamlLint::Lint.new( HamlLint::Linter::Syntax.new(config), document.file, location.line, ex.to_s, :error ) end |