Giter VIP home page Giter VIP logo

slim-lint's Introduction

Personal web site, powered by Jekyll.

slim-lint's People

Contributors

ajclaasen avatar alainmeier avatar andreaswachowski avatar anthony-robin avatar borama avatar coorasse avatar dkniffin avatar doits avatar dziemba avatar elstgav avatar ibrahima avatar maksimabramchuk avatar mattbrictson avatar michaelbaudino avatar michaelherold avatar mmzoo avatar nicolas-brousse avatar olleolleolle avatar opodartho avatar pocke avatar printercu avatar ryo1107 avatar sds avatar smasato avatar t2h5 avatar tagliala avatar walf443 avatar ybiquitous avatar yjukaku avatar zinahia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

slim-lint's Issues

ruby parser errors

I started getting this error in my application and I am concerned it is related to ruby 2.3.0

-->> slim-lint /Users/chrishough/Studio/Code-Consulting/bilingualhire/app/**/*.slim --config=.slimlint.yml
warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2.x-compliant syntax, but you are running 2.3.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.

Show number of files inspected

It would be nice to show a message after executing slim-lint to know what was inspected, as currently if there are no offences nothing is shown and it is easy to think that something went wrong.

A message similar to the once used by Rubocop would work here as well:

80 files inspected, no offenses detected

rake -T does not work

rake -T                                                                                                                                                1 ↵ ✹ ✭ [12:06:31]
rake aborted!
NameError: uninitialized constant SlimLint::APP_NAME
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/slim_lint-0.5.0/lib/slim_lint/rake_task.rb:115:in `default_description'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/slim_lint-0.5.0/lib/slim_lint/rake_task.rb:70:in `define'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/slim_lint-0.5.0/lib/slim_lint/rake_task.rb:63:in `initialize'
/Users/justin/clients/madrone/investor-dashboard/lib/tasks/linters.rake:21:in `new'
/Users/justin/clients/madrone/investor-dashboard/lib/tasks/linters.rake:21:in `<top (required)>'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/railties-4.2.0/lib/rails/engine.rb:658:in `block in run_tasks_blocks'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/railties-4.2.0/lib/rails/engine.rb:658:in `each'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/railties-4.2.0/lib/rails/engine.rb:658:in `run_tasks_blocks'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/railties-4.2.0/lib/rails/application.rb:438:in `run_tasks_blocks'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/railties-4.2.0/lib/rails/engine.rb:453:in `load_tasks'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/railties-4.2.0/lib/rails/railtie.rb:194:in `public_send'
/Users/justin/.rvm/gems/ruby-2.2.1@madrone/gems/railties-4.2.0/lib/rails/railtie.rb:194:in `method_missing'
/Users/justin/clients/madrone/investor-dashboard/Rakefile:7:in `<top (required)>'
(See full trace by running task with --trace)

emacs-x86_64-10_9_justinmbp_local_______users_justin__rvm_gems_ruby-2_2_1_madrone_gems_slim_lint-0_5_0_lib_slim_lint_rake_task_rb____12_18pm_4_01

But I see the constant defined. Seems like some order that the modules are loaded or not loaded is causing this issue.

Any ideas? @sds?

Spacing convention between element name and equal sign (div= versus div =)

I noticed inconsistency when my colleagues, who are used to Haml, transision to Slim:

Notice the space before the = sign:

/ Good
div = 'This is what the official slim documentation uses consistently'

/ Bad
div= 'This works, but it should probably not be encouraged.'

/ Not affected
a href="This is still fine though, because it is an attribute"

I also noticed that my syntax highlighter (TextMate) doesn't properly recognize the non-spacing version:

screen shot 2018-07-16 at 10 14 47

Would this cop be something worth implementing?

(I tried twice to bugfix some rubocop internals and failed miserably somewhere in the AST 😂, so I cannot promise a PR, but I will try if you think this cop makes sense :)

warning: found = in conditional, should be == invalid

Getting this error after gem updates.

 warning: found = in conditional, should be ==

from this structure

- if @presenter.form_adv
  - if @presenter.peer_group
    #employee-composition.row
      - if @presenter.form_adv.has_employees?
        .col-sm-12.col-md-6.col-print-12
          #employee_composition_vs_peers.chart-container.chart-resizeable data-max-height=700
        .col-sm-12.col-md-6.col-print-12
          #employee_vs_assets.chart-container.chart-resizeable data-max-height=700

Leading whitespace linter

I'd like a linter that checks for verbatim text that has leading whitespace. I had a go at creating this linter and came up with the following:

module SlimLint
  # Searches for verbatim text with leading whitespace
  class Linter::LeadingWhitespace < Linter
    include LinterRegistry

    on [:slim, :text, :verbatim] do |sexp|
      _, _, _, content = sexp
      next unless content[/\A\s+/] # This line is obviously wrong

      report_lint(sexp, 'Line contains leading whitespace')
    end
  end
end

With this simple test:

context 'when line contains leading spaces' do
  let(:slim) { "'  Text with unecessary whitespace" }

  it { should report_lint line: 1 }
end

content ends up being:

[<#Atom :multi>, [<#Atom :slim>, <#Atom :interpolate>, <#Atom " Text with unecessary whitespace">]]

I'm not sure what the best way to match on this and extract the text so that it can be checked for leading whitespace.

Are you able to point me in the right direction?

Law of demeter

Not sure it could be implemented but it will be great to have a cop to catch things like this

= post.author.posts.count

Any thought?

Missing runtime dependency Astrolabe

This gem has a runtime dependency on the gem Astrolabe which is used in the file ruby_parser.rb#L1.

Previously this dependency was brought in through Rubocop, but as of Rubocop-0.36.0 this is no longer the case. Adding it as a runtime dependency should fix this issue (or lock the version of Rubocop to 0.35.1).

The error caused by this missing dependency is LoadError: cannot load such file -- astrolabe/builder

Linter ControlStatementSpacing raise incorrect `=`

It's weird why ControlStatementSpacing linter keeps raising Please add a space before and after the = even I didn't see any isse.

div layout="column" layout-gt-sm=="row" ng-show="search_meta.total_pages | valPresent"
  .app-bg-color.md-primary.search-result flex=true
    | Search Results ({{ search_meta.total_count }} {{ search_meta.total_count > 1 ? 'documents' : 'document' }})
  .pagination.app-pagination[flex=true
    layout="row"
    layout-align="center center"
    layout-align-gt-sm="end center"
    ng-show="search_meta.total_pages > 1"]
      md-button.app-color-hover.app-primary[ng-href="{{ searchURL({page: 1}) }}"
        ng-disabled="search_meta.current_page == 1"
        aria-label=online_t(:first_page, scope: %i(document actions search))]
          md-icon.md-dark first_page
          md-tooltip md-direction="bottom" = online_t(:first_page, scope: %i(document actions search))
      md-button.app-color-hover.app-primary[ng-href="{{ searchURL({page: search_meta.prev_page}) }}"
        ng-disabled="search_meta.prev_page == null"
        aria-label=online_t(:prev_page, scope: %i(document actions search))]
          md-icon.md-dark keyboard_arrow_left
      md-button.app-primary[ng-repeat="page in searchNavPages(search_meta, search_meta.current_page)"
        ng-href="{{ searchURL({page: page}) }}"
        ng-class="{'app-bg-color': search_meta.current_page == page, \
        'app-color-hover': search_meta.current_page != page}"
        ng-bind="page"]
      md-button.app-color-hover.app-primary[ng-href="{{ searchURL({page: search_meta.next_page}) }}"
        ng-disabled="search_meta.next_page == null"
        aria-label=online_t(:next_page, scope: %i(document actions search))]
          md-icon.md-dark keyboard_arrow_right
          md-tooltip md-direction="bottom" = online_t(:next_page, scope: %i(document actions search))
      md-button.app-color-hover.app-primary[ng-href="{{ searchURL({page: search_meta.total_pages}) }}"
        ng-disabled="search_meta.current_page == search_meta.total_pages"
        aria-label=online_t(:last_page, scope: %i(document actions search))]
          md-icon.md-dark last_page
          md-tooltip md-direction="bottom" = online_t(:last_page, scope: %i(document actions search))

WARNINGS:

app/views/online/templates/_search_pagination.html.slim:26 [W] ControlStatementSpacing: Please add a space before and after the `=`
app/views/online/templates/_search_pagination.html.slim:31 [W] ControlStatementSpacing: Please add a space before and after the `=`

Dependencies:

slim_lint (0.17.0)
      rake (>= 10, < 13)
      rubocop (>= 0.50.0)
      slim (>= 3.0, < 5.0)
      sysexits (~> 1.1)

Rubocop Failure Message reported as Warning

I created a new rails app using https://github.com/RailsApps/rails-composer

I added overcommit and slim-lint.

I'm getting an error message "(Using Ruby 2.3 parser; configure using TargetRubyVersion parameter, under AllCops)" with TargetRubyVersion already specified in .rubocop.rb.

This only occurs when I run slim-lint against a list of all slim files.

$ slim-lint **/*.slim
(Using Ruby 2.3 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)

It does not occur when run against a specific directory:

$ slim-lint app/views/layouts/*.slim

slim-lint failed with exit code 65

Given a slim template with the following contents:

ruby:
  ->() { derp}

Running bin/rake slim_lint fails:

./app/views/courses/dj/_dj.slim:2 [W] RuboCop: Space missing inside }.
rake aborted!
slim-lint failed with exit code 65

`exclude` does not work in 0.15.1

Hi!

Here is my config:

linters:
  LineLength:
    max: 100
    exclude:
    - app/views/site/abouts/terms_and_conditions.html.slim

It ignores the file in 0.15.0 but not in 0.15.1. Also all paths for warnings are shown expanded instead of relative to project root. Seems like ef9a07f caused this issue.

False positives in 0.16

New slim lint does not see final new line for some reasons.
It shows messages "Use 2 (not 0) spaces for indentation." that remain unchanged with any indentation changes.

Example:

.row
  .columns
    h2 = title("Forgot your password?")

.row
  .medium-5.columns
    = simple_form_for resource,
      as: resource_name,
      url: password_path(resource_name),
      html: { method: :post  } do |f|

      .form-inputs
        = f.input :email, required: true
      .form-actions
        = f.button :submit, "Send me reset password instructions"

  .medium-5.medium-offset-1.columns.end
    = render "admins/shared/links"

No matter how I move params from line 8, it says "Use one level of indentation for parameters following the first line of a multi-line method call."

Linter ControlStatementSpacing raises warning on inline => or =< syntax

Now that ControlStatementSpacing is a default linter, and following #85, I have several warnings raising about usage of output operator with leading/trailing when I use it inline with a tag

p
  ' This
  b => product.name        # Lint warning
  ' product is astonishing

I could jump a line to get rid of the linter warning, but I like keep my slim file with few lines possible

p
  ' This
  b
    => product.name        # No Lint warning
  ' product is astonishing

Actually I wonder if it's a officially supported use-case as I cannot find any example of using slim syntax this way in the official documentation

https://www.rubydoc.info/gems/slim/frames#Output__

Output with trailing white space =>. Same as the single equals sign (=), except that it adds a trailing white space.
Output with leading white space =<. Same as the single equals sign (=), except that it adds a leading white space.

I don't know if slim-lint is about to consider having linters options like we can find in Rubocop for instance. It might be a good case here to specify wether "inline" output usage should be tolerated or enforced to a newline (without having any clue on about to propose a PR for that yet, sorry).

Can slim-lint autocorrect problems?

Is there a way for me to run slim-lint and have all hash-rocket syntax occurances be automatically turned into Ruby 1.9 hash syntax? I expect something like: rubocop --only HashSyntax --auto-correct. Thank you 😄

Cannot integrate with rubocop, overcommit

I've been trying to integrate slim-lint with rubocop and overcommit this morning, and have yet to be able to have it successfully run either rubocop is run, or when a commit is made. The instructions given in README are somewhat sparse. What I've tried so far:

  • Adding the following to .overcommit.yml:
SlimLint:
    enabled: true
    on_warn: fail # Treat all warnings as failures
  • Adding the following to .rubocop.yml:
SlimLint:
  enabled: true
  • Adding require: slim_lint to rubocop.yml

What is the current mechanism for integrating slim-lint with rubocop?

"Style/IdenticalConditionalBranches: Move `something` out of the conditional" is wrong interpreted.

If I have this code for example:

- if condition?
    a[target='_blank' href='#'] = name
- else
  = name

Slim would now report this error two times:

[W] RuboCop: Style/IdenticalConditionalBranches: Move `name` out of the conditional.

Here is the logic behind it' s report.

But unfortunately in this case it is not possible to move name out of the condition, because either the name of the link would be equal to name or something on above the condition (for example a p tag).
I am aware that I could've used the rails link_to method and the problem wouldn't have appeared. The usage of the a tag here is just to demonstrate my point.

I expect slim to recognise when the element used, in both the if and the else block, is called in void context or assigned to something.

Problem with slim-lint, rubocop and Style/IndentHash

Hi,

I'm using slim-lint and rubocop.

This code:

= select_tag :c,
  data: {\
    a: 'b'}

gives me that warning:

index.html.slim:3 [W] RuboCop: Style/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.

To be honest I'm not sure what could wrong with my code. Any ideas?

Rubocop error on safe navigation operator

In my template, I want to use the relatively new safe navigation operator like this:

= @some_object&.name

Since the object might be nil, so I use the safe navigation operator to prevent errors. However, rubocop errors on that line with Rubocop: Lint/Syntax: unexpected token error, making Atom warn me on normally valid syntax.

I'm not sure if it is because of Rubocop or slim_lint, but normally Rubocop doesn't crash on the &, so that's why I'm listing it here

ancient browser check file

app/views/layouts/application/_ancient_browser_check.html.slim:2 [W] LineLength: Line is too long. [260/120]

Here's the file

/ noinspection LineLength
/![if lt IE 7] <p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p

What do you recommend?

Incompatible with latest rubocop (currently 0.35)

rubocop 0.34.1

bundle | ggrep -E '(rubo|slim_lint)'
Using rubocop 0.34.1
Using slim_lint 0.6.1
bundle exec slim-lint app/views
echo $? #=> 0

rubocop 0.35.1

bundle | ggrep -E '(rubo|slim_lint)'
Using rubocop 0.35.1
Using slim_lint 0.6.1
An error occurred while Style/AlignParameters cop was inspecting /Users/jared/redacted/app/views/redacted.slim.slim_lint.tmp20160106-48574-t4fjq4.
To see the complete backtrace run rubocop -d.

1 error occurred:
An error occurred while Style/AlignParameters cop was inspecting /Users/jared/redacted/app/views/redacted.slim.slim_lint.tmp20160106-48574-t4fjq4.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.35.1 (using Parser 2.2.3.0, running on ruby 2.2.3 x86_64-darwin14)
An error occurred while Style/AlignParameters cop was inspecting /Users/jared/redacted/app/views/redacted.slim.slim_lint.tmp20160106-48574-1jekafi.
To see the complete backtrace run rubocop -d.
An error occurred while Style/AlignParameters cop was inspecting /Users/jared/redacted/app/views/redacted.slim.slim_lint.tmp20160106-48574-1jekafi.
To see the complete backtrace run rubocop -d.

2 errors occurred:
An error occurred while Style/AlignParameters cop was inspecting /Users/jared/redacted/app/views/redacted.slim.slim_lint.tmp20160106-48574-1jekafi.
An error occurred while Style/AlignParameters cop was inspecting /Users/jared/redacted/app/views/redacted.slim.slim_lint.tmp20160106-48574-1jekafi.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.35.1 (using Parser 2.2.3.0, running on ruby 2.2.3 x86_64-darwin14)
An error occurred while Style/AlignParameters cop was inspecting /Users/jared/redacted/app/views/redacted.slim.slim_lint.tmp20160106-48574-1hzi2bk.
To see the complete backtrace run rubocop -d.

1 error occurred:
An error occurred while Style/AlignParameters cop was inspecting /Users/jared/redacted/app/views/redacted.slim.slim_lint.tmp20160106-48574-1hzi2bk.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.35.1 (using Parser 2.2.3.0, running on ruby 2.2.3 x86_64-darwin14)
echo $? #=> 0

It says "To see the complete backtrace run rubocop -d." but if I did that it would just run rubocop, not slim-lint. Please let me know how I can help provide more information.

[Enquiry] Linter not reporting syntax errors

Description

Following line in a slim template

select{id= 'select_this', name= 'sure_name', data= {placeholder: t('view.some_data')}}

would cause the following error on render

ActionView::Template::Error (Multiple , attributes specified):

However, linter is quiet about that.
Is slim-lint capable of catching such errors?

In-memory file analysis

Hi,

I've noticed that slim-lint is creating a .rb file in the same folder of the file to inspect (which causes git clients to continuously see new files).

Is there any chance of doing this in memory or using stdoutput or at worst in a temporary dir like application's /tmp?

Thanks

Better flycheck support

I opened flycheck/flycheck#1102 because I noticed that Flycheck+Slim-lint was not respecting the .rubycop.yml in my projects main folder. This stems from flycheck copying the file to be linted to a temp folder. I suspect it would also not respect the .slim-lint.yml but that is easily fixed by passing the path to it with --config.

I read through the code and found there is a way to pass the path of the rubocop config through an environment variable, but I am told that flycheck does not support this currently. There are a couple of different solutions to this as I see it:

  1. Allow slim-lint to take the source from STDIN and pass a flag to override the file path, this seems to be preferred by flycheck according to flycheck/flycheck#1102.
  2. Add flag to slim-lint to accept rubocop config path on the command line.
  3. Something I haven't thought of yet

I wanted to open an issue first to start a conversation instead of just dropping a PR. What would be preferred from the slim-lint side? I am happy to take a stab at a PR, just wanted to get some insight first.

Display wrong line number

Slim-lint display wrong line number for errors when ruby code is written in multiple lines. If ruby code break down into multiple line then slim-lint should count this as multiple line not one line.

Here is a screenshot:
Screenshot

Redundant div is in line 19 but error displaying in line 15.

Add check for invalid keys in config files

It is currently possible to include invalid linter names in the config file. If an invalid name is included, an error should be thrown rather than silently ignoring it. (As seen here #31)

LineLength class

I use SublimeLinter-slim-lint plugin for Sublime Text. Example of my Example.slim file:

| Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

In Status Bar I saw message:

LineLength: Line is too long [448/80]

I have 2 questions:

  1. Why do we need class LineLength? What is it good?
  2. How can I disable this class?

I have tried:

C:\WINDOWS\system32>slim-lint --show-linters
Available linters:
+ CommentControlStatement
+ ConsecutiveControlStatements
+ EmptyControlStatement
+ LineLength
+ RedundantDiv
+ RuboCop
+ TagCase
+ TrailingWhitespace

C:\WINDOWS\system32>slim-lint -x LineLength

C:\WINDOWS\system32>slim-lint --show-linters
Available linters:
+ CommentControlStatement
+ ConsecutiveControlStatements
+ EmptyControlStatement
+ LineLength
+ RedundantDiv
+ RuboCop
+ TagCase
+ TrailingWhitespace

The class is not disabled.

I read #12. Whether correctly I understood, what time can't disconnect separate linters at the moment?

Thanks.

Disable/enable rubocop linters via comments

Could you give me a hint on why the following does not work?

I still get [W] LineLength: Line is too long. [461/120]

/ rubocop:disable Metrics/LineLength
        iframe [class="embed-responsive-item"
          src="https://www.productreview.com.au/w/reviews/280683.html?_sf_ignore_cache=1&amp;api_version=2&amp;referer=http%3A%2F%2Fwww.carnextdoor.com.au%2Fcar-next-door-reviews%2F&amp;url=https://www.productreview.com.au/w/reviews/&amp;css_override=false&amp;min_review_rating=0&amp;min_avg_rating=0&amp;order=best&amp;num_reviews=3&amp;width=800&amp;height=290&amp;preview=true&amp;xdm_e=http%3A%2F%2Fwww.carnextdoor.com.au&amp;xdm_c=default1590&amp;xdm_p=1"
          name="easyXDM_default1590_provider" id="easyXDM_default1590_provider"]
        / rubocop:enable Metrics/LineLength

Linter Idea: Check For Hard Coded Text

I need to implement a linter that checks if there is any hard coded text (instead of i18n translations or method calls in general) for a project. So I wondered whether this project is a good place for this linter to live.

Here are some examples:

.foo
  | This is bad

.foo
  = t('.this_is_good')

.foo
  = this_is_also_ok(42)

invalid byte sequence in US-ASCII

Run slim-lint on index.html.slim with cyrillic symbols at CI server and got:

ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]

warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2.3-compliant syntax, but you are running 2.2.0.
invalid byte sequence in US-ASCII
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/document.rb:41:in `split'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/document.rb:41:in `process_source'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/document.rb:32:in `initialize'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/runner.rb:52:in `new'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/runner.rb:52:in `collect_lints'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/runner.rb:21:in `block in run'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/runner.rb:20:in `map'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/runner.rb:20:in `run'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/cli.rb:82:in `scan_for_lints'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/cli.rb:51:in `act_on_options'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/lib/slim_lint/cli.rb:23:in `run'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/gems/slim_lint-0.5.0/bin/slim-lint:6:in `<top (required)>'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/bin/slim-lint:23:in `load'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/bin/slim-lint:23:in `<main>'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `eval'
/home/gitlab_ci_runner/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in `<main>'
Report this bug at https://github.com/sds/slim-lint/issues

Add checkstyle compatible reporter

This would make it much easier to integrate with Jenkins.

Rubocop for example has a plugin to do this: https://github.com/eitoball/rubocop-checkstyle_formatter

The format itself is pretty simple. For example:

<?xml version='1.0'?>
<checkstyle>
  <file name='Gemfile'/>
  <file name='config.ru'>
    <error line='37' column='27' severity='info' message='Avoid using `{...}` for multi-line blocks.' source='com.puppycrawl.tools.checkstyle.Style/BlockDelimiters'/>
    <error line='39' column='20' severity='info' message='Redundant curly braces around a hash parameter.' source='com.puppycrawl.tools.checkstyle.Style/BracesAroundHashParameters'/>
  </file>

invalid Do not use prefix `_` for a variable that is used.

slim-lint app/views

app/views/devise/confirmations/new.html.slim:3 [W] RuboCop: Lint/UnderscorePrefixedVariableName: Do not use prefix `_` for a variable that is used.

I don't see any _ variable

h2
  | Resend confirmation instructions
= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f|
  = f.error_notification
  = f.full_error :confirmation_token
  .form-inputs
    = f.input :email, required: true, autofocus: true
  .form-actions
    = f.button :submit, "Resend confirmation instructions"
= render "devise/shared/links"

generate slim_lint_todo

Hi,
is there a way to generate a todo file like rubocops .rubocop_todo.yml?
I'm having too many linting errors right now and it would be nice if i could deal with old issues later™️.

False-positive UselessAssignment when in a slim capture block

This is a simple recreation of the issue I bumped into with a form_for helper in rails. I'm using capture so that it's distilled down to the essence of the issue:

- url = 'https://google.com'
= capture do
  a href=url = 'Google'

Running slim-lint on this gives me:

test.html.slim:2 [W] RuboCop: Useless assignment to variable - `url`.

Triggers Naming/FileName cop with RuboCop 0.50.0

app/views/admin/users/index.html.slim:1 [W] RuboCop: Naming/FileName: The name of this source file (`index.html.slim.slim_lint.tmp20170917-92660-1io5a15.rb`) should use snake_case.

Workaround:

linters:
  RuboCop:
    enabled: true
    # These cops are incredibly noisy since the Ruby we extract from Slim
    # templates isn't well-formatted, so we ignore them.
    # WARNING: If you define this list in your own .slim-lint.yml file, you'll
    # be overriding the list defined here.
    ignored_cops:
      - Layout/AlignArray
      - Layout/AlignHash
      - Layout/AlignParameters
      - Layout/FirstParameterIndentation
      - Layout/IndentArray
      - Layout/IndentationConsistency
      - Layout/IndentationWidth
      - Layout/MultilineArrayBraceLayout
      - Layout/MultilineAssignmentLayout
      - Layout/MultilineHashBraceLayout
      - Layout/MultilineMethodCallBraceLayout
      - Layout/MultilineMethodCallIndentation
      - Layout/MultilineMethodDefinitionBraceLayout
      - Layout/MultilineOperationIndentation
      - Layout/TrailingBlankLines
      - Layout/TrailingWhitespace
      - Lint/BlockAlignment
      - Lint/EndAlignment
      - Lint/Void
      - Metrics/BlockLength
      - Metrics/BlockNesting
      - Metrics/LineLength
      - Naming/FileName
      - Style/FrozenStringLiteralComment
      - Style/IfUnlessModifier
      - Style/Next
      - Style/WhileUntilModifier

I would rather replace dashes with underscore in temporary files for a better fix and leave that linter enabled

simple_form templates

heartcombo/simple_form#1100

Any way to avoid directories like lib/templates/slim/scaffold?

Note, this does not happen with the rake task.

I ran this like

slim-lint app/**/*.slim
./lib/templates/slim/scaffold/_form.html.slim:1 [W] RuboCop: Syntax: unexpected `@'

Here's the file:

= simple_form_for(@<%= singular_table_name %>) do |f|
  = f.error_notification

  .form-inputs
<%- attributes.each do |attribute| -%>
    = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
<%- end -%>

  .form-actions
    = f.button :submit

BTW -- LOOKS AWESOME!

slim-lint failed with exit code 70 (slim-lint 0.7.0)

I also tried with RuboCop 0.37.0 and MRI Ruby 2.2.3 but got the same error. Let me know if you need any more information.

> bundle exec rake slim_lint --trace
** Invoke slim_lint (first_time)
** Execute slim_lint
no block given
/Users/me/.rvm/gems/ruby-2.2.4@my_app/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/me/.rvm/gems/ruby-2.2.4@my_app/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/me/.rvm/gems/ruby-2.2.4@my_app/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Report this bug at https://github.com/sds/slim-lint/issues

To help fix this issue, please include:
- The above stack trace
- Slim-Lint version: 0.7.0
- RuboCop version: 0.36.0
- Ruby version: 2.2.4
rake aborted!
slim-lint failed with exit code 70
/Users/me/.rvm/gems/ruby-2.2.4@my_app/gems/slim_lint-0.7.0/lib/slim_lint/rake_task.rb:91:in `run_cli'
/Users/me/.rvm/gems/ruby-2.2.4@my_app/gems/slim_lint-0.7.0/lib/slim_lint/rake_task.rb:78:in `block in define'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/me/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/me/.rvm/rubies/ruby-2.2.4/bin/rake:33:in `<main>'
Tasks: TOP => slim_lint

BlockLength cop: ignore it by default?

Hi, what do you think about ignoring the above cop by default? It is noisy for slim templates and it doesn't report the proper number of lines

e.g.:

.table-responsive
  table.table.table-striped
    tbody
      - elements.each do |element|
        tr
          td= link_to element
          - if element.editable?
            td.btn-toolbar
              = link_to edit_element_path(itinerary), class: 'btn btn-xs btn-default' do
                span.fa.fa-pencil<> aria-hidden='true'
                = t('.edit')
              = link_to element_path(itinerary), method: :delete, data: { confirm: t('.confirm') }, class: 'btn btn-xs btn-danger' do
                span.fa.fa-trash<> aria-hidden='true'
                = t('.destroy')
          - else
            td= t('.read_only')

Output:

_table.html.slim:4 [W] RuboCop: Block has too many lines. [28/25]

Current workaround:

linters:
  RuboCop:
    ignored_cops:
      - Lint/BlockAlignment
      - Lint/EndAlignment
      - Lint/Void
      - Metrics/BlockLength # TODO: https://github.com/sds/slim-lint/issues/49
      - Metrics/LineLength
      - Style/AlignHash
      - Style/AlignParameters
      - Style/BlockNesting
      - Style/FileName
      - Style/FirstParameterIndentation
      - Style/FrozenStringLiteralComment
      - Style/IfUnlessModifier
      - Style/IndentationConsistency
      - Style/IndentationWidth
      - Style/MultilineArrayBraceLayout
      - Style/MultilineAssignmentLayout
      - Style/MultilineHashBraceLayout
      - Style/MultilineMethodCallBraceLayout
      - Style/MultilineMethodDefinitionBraceLayout
      - Style/MultilineMethodCallIndentation
      - Style/MultilineOperationIndentation
      - Style/Next
      - Style/TrailingBlankLines
      - Style/TrailingWhitespace
      - Style/WhileUntilModifier

Relative `exclude` paths don't work when when run via overcommit

My project has a .slim-lint.yml in the root of the project containing the following:

exclude:
  - 'lib/templates/slim/**/*'

When run via overcommit, the exclusion is not honored:

$ overcommit -r
Analyze with slim-lint.....................................[SlimLint] FAILED
Unexpected output: unable to determine line number or type of error/warning for output:
(Using Ruby 2.4 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)
/Users/mbrictson/Code/my-rails-app/lib/templates/slim/scaffold/_form.html.slim:6 [W] RuboCop: Lint/Syntax: unexpected token tIDENTIFIER

From what I can tell, this is because overcommit calls the slim-lint command with a list of absolute paths. These absolute paths don't match when compared to the relative exclude pattern.

My current workaround is to prepend a glob wildcard like this:

exclude:
  # Leading "**" is needed for compatibility with overcommit
  - '**/lib/templates/slim/**/*'

However I think a better solution would be for slim-lint to resolve relative paths as relative to the location of the .slim-lint.yml file. This would be consistent with RuboCop's behavior: rubocop/rubocop#892

Rubocop errors reported on wrong lines in some cases

I'm not sure what's causing this yet, but I just wanted to report this with an example to reproduce so that maybe you or I can figure out what is happening here and fix it.

I'm experiencing an issue where slim-lint reports Rubocop errors on the wrong line instead of the line that actually caused the errors. The possible cause seems to be the presence of other linter errors (long line errors, mostly) on the same line; removing some of those long lines moves the phantom error around and in some cases fixes the issue. Here's an example file that displays the issue:

- provide :title, 'Title'
- provide :viewport, 'desktop'

= render 'partials/sidebar'

- action_bar do
  div.action-bar-label
    = fa_icon('spinner', class: 'fa-spin')
    | Loading...

#content-container
  h1 Heading

  .instructions-and-upload-form
    .instructions
      p
        | Some instruction text.
          A very long line consisting of some more instructions, which goes over the slim-lint maximum line length.
          More instruction text.
      - if @some_variable > 0
        p
          | A very long line consisting of some more instructions, which goes over the slim-lint maximum line length.
            A very long line consisting of some more instructions, which goes over the slim-lint maximum line length. #{link_to "link_text", some_rails_path_helper(@model1, @model2)}.
            A very long line consisting of some more instructions, which goes over the slim-lint maximum line length. <strong>Do something</strong>.
    .upload-form
      = form_for @attachment, role: 'form', url: some_rails_path_helper_that_makes_this_line_too_long(@model1, @model2) do |f|
        = f.labeled_file_upload :file, "Select", "Files", multiple: true, data: { prompt: "Select file(s)" }
        = f.submit "Upload files(s)", id: "submit", class: ['btn', 'btn-primary']

  = react_component('MyReactApp',
      arg1: @arg1, arg2: @arg2, arg3: @arg3, arg4: @arg4)

(gist)

And here's the output:

broken_lints.slim:7 [W] RedundantDiv: `div` is redundant when class attribute shortcut is present
broken_lints.slim:18 [W] LineLength: Line is too long. [115/80]
broken_lints.slim:22 [W] LineLength: Line is too long. [117/80]
broken_lints.slim:23 [W] LineLength: Line is too long. [183/80]
broken_lints.slim:24 [W] LineLength: Line is too long. [148/80]
broken_lints.slim:26 [W] LineLength: Line is too long. [126/80]
broken_lints.slim:26 [W] RuboCop: Prefer single-quoted strings when you don't need string interpolation or special symbols.
broken_lints.slim:27 [W] LineLength: Line is too long. [108/80]
broken_lints.slim:28 [W] LineLength: Line is too long. [81/80]
broken_lints.slim:31 [W] RuboCop: Prefer single-quoted strings when you don't need string interpolation or special symbols.
broken_lints.slim:31 [W] RuboCop: Prefer single-quoted strings when you don't need string interpolation or special symbols.
broken_lints.slim:31 [W] RuboCop: Prefer single-quoted strings when you don't need string interpolation or special symbols.
broken_lints.slim:32 [W] RuboCop: Prefer single-quoted strings when you don't need string interpolation or special symbols.
broken_lints.slim:32 [W] RuboCop: Prefer single-quoted strings when you don't need string interpolation or special symbols.

As you can see, the double-quoted strings lints are on the wrong line, since line 31 doesn't have any double quoted strings, and there is no line 32.

Again, if I have time, I might look into this myself, but I just thought I should report the bug so that you're aware of it. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.