slim_lint 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.md +21 -0
- data/lib/slim_lint/atom.rb +1 -6
- data/lib/slim_lint/configuration.rb +0 -1
- data/lib/slim_lint/configuration_loader.rb +4 -2
- data/lib/slim_lint/constants.rb +6 -4
- data/lib/slim_lint/document.rb +3 -1
- data/lib/slim_lint/file_finder.rb +1 -1
- data/lib/slim_lint/linter/line_length.rb +3 -1
- data/lib/slim_lint/linter/redundant_div.rb +3 -1
- data/lib/slim_lint/linter_selector.rb +4 -4
- data/lib/slim_lint/ruby_extractor.rb +9 -3
- data/lib/slim_lint/ruby_parser.rb +3 -2
- data/lib/slim_lint/sexp.rb +6 -5
- data/lib/slim_lint/utils.rb +2 -2
- data/lib/slim_lint/version.rb +3 -1
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b31bbab7032a0b6e0da094200bf36f78e3c432db
|
4
|
+
data.tar.gz: 8d431de357a8880ea02697529fb6b59aa96a26b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 083c79d40d3c6aadf7329d052f834b951041caf439659c608df155cff0a89f4239bcb2d0924b3beb2804278e13e1c72f496b6c870407506bf96df8f78dc747e4
|
7
|
+
data.tar.gz: 2aa7a953372da42bc9562a91839a0cece3da71c4189875afc2ef0c7dd5856882964b9cea6c9e6803a0e3f172025ae95a60d2883e44378f4fd2f7e05925942be0
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Slim-Lint is released under the MIT license.
|
2
|
+
|
3
|
+
> Copyright (c) 2015 Shane da Silva. http://shane.io
|
4
|
+
>
|
5
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
> of this software and associated documentation files (the "Software"), to deal
|
7
|
+
> in the Software without restriction, including without limitation the rights
|
8
|
+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
> copies of the Software, and to permit persons to whom the Software is
|
10
|
+
> furnished to do so, subject to the following conditions:
|
11
|
+
>
|
12
|
+
> The above copyright notice and this permission notice shall be included in
|
13
|
+
> all copies or substantial portions of the Software.
|
14
|
+
>
|
15
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
> SOFTWARE.
|
data/lib/slim_lint/atom.rb
CHANGED
@@ -20,12 +20,7 @@ module SlimLint
|
|
20
20
|
# @param other [Object]
|
21
21
|
# @return [Boolean]
|
22
22
|
def ==(other)
|
23
|
-
|
24
|
-
when Atom
|
25
|
-
@value == other.instance_variable_get(:@value)
|
26
|
-
else
|
27
|
-
@value == other
|
28
|
-
end
|
23
|
+
@value == (other.is_a?(Atom) ? other.instance_variable_get(:@value) : other)
|
29
24
|
end
|
30
25
|
|
31
26
|
# Returns whether this atom matches the given Sexp pattern.
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
require 'yaml'
|
3
5
|
|
4
6
|
module SlimLint
|
5
7
|
# Manages configuration file loading.
|
6
8
|
class ConfigurationLoader
|
7
|
-
DEFAULT_CONFIG_PATH = File.join(SlimLint::HOME, 'config', 'default.yml')
|
8
|
-
CONFIG_FILE_NAME = '.slim-lint.yml'
|
9
|
+
DEFAULT_CONFIG_PATH = File.join(SlimLint::HOME, 'config', 'default.yml').freeze
|
10
|
+
CONFIG_FILE_NAME = '.slim-lint.yml'.freeze
|
9
11
|
|
10
12
|
class << self
|
11
13
|
# Load configuration file given the current working directory the
|
data/lib/slim_lint/constants.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Global application constants.
|
2
4
|
module SlimLint
|
3
|
-
HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
4
|
-
APP_NAME = 'slim-lint'
|
5
|
+
HOME = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
|
6
|
+
APP_NAME = 'slim-lint'.freeze
|
5
7
|
|
6
|
-
REPO_URL = 'https://github.com/sds/slim-lint'
|
7
|
-
BUG_REPORT_URL = "#{REPO_URL}/issues"
|
8
|
+
REPO_URL = 'https://github.com/sds/slim-lint'.freeze
|
9
|
+
BUG_REPORT_URL = "#{REPO_URL}/issues".freeze
|
8
10
|
end
|
data/lib/slim_lint/document.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlimLint
|
2
4
|
# Represents a parsed Slim document and its associated metadata.
|
3
5
|
class Document
|
4
6
|
# File name given to source code parsed from just a string.
|
5
|
-
STRING_SOURCE = '(string)'
|
7
|
+
STRING_SOURCE = '(string)'.freeze
|
6
8
|
|
7
9
|
# @return [SlimLint::Configuration] Configuration used to parse template
|
8
10
|
attr_reader :config
|
@@ -6,7 +6,7 @@ module SlimLint
|
|
6
6
|
class FileFinder
|
7
7
|
# List of extensions of files to include under a directory when a directory
|
8
8
|
# is specified instead of a file.
|
9
|
-
VALID_EXTENSIONS = %w[.slim]
|
9
|
+
VALID_EXTENSIONS = %w[.slim].freeze
|
10
10
|
|
11
11
|
# Create a file finder using the specified configuration.
|
12
12
|
#
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlimLint
|
2
4
|
# Checks for lines longer than a maximum number of columns.
|
3
5
|
class Linter::LineLength < Linter
|
4
6
|
include LinterRegistry
|
5
7
|
|
6
|
-
MSG = 'Line is too long. [%d/%d]'
|
8
|
+
MSG = 'Line is too long. [%d/%d]'.freeze
|
7
9
|
|
8
10
|
on_start do |_sexp|
|
9
11
|
max_length = config['max']
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SlimLint
|
2
4
|
# Checks for unnecessary uses of the `div` tag where a class name or ID
|
3
5
|
# already implies a div.
|
4
6
|
class Linter::RedundantDiv < Linter
|
5
7
|
include LinterRegistry
|
6
8
|
|
7
|
-
MESSAGE = '`div` is redundant when %s attribute shortcut is present'
|
9
|
+
MESSAGE = '`div` is redundant when %s attribute shortcut is present'.freeze
|
8
10
|
|
9
11
|
on [:html, :tag, 'div',
|
10
12
|
[:html, :attrs,
|
@@ -29,13 +29,13 @@ module SlimLint
|
|
29
29
|
# @param options [Hash]
|
30
30
|
# @return [Array<SlimLint::Linter>]
|
31
31
|
def extract_enabled_linters(config, options)
|
32
|
-
included_linters =
|
33
|
-
.extract_linters_from(options.fetch(:included_linters, []))
|
32
|
+
included_linters =
|
33
|
+
LinterRegistry.extract_linters_from(options.fetch(:included_linters, []))
|
34
34
|
|
35
35
|
included_linters = LinterRegistry.linters if included_linters.empty?
|
36
36
|
|
37
|
-
excluded_linters =
|
38
|
-
.extract_linters_from(options.fetch(:excluded_linters, []))
|
37
|
+
excluded_linters =
|
38
|
+
LinterRegistry.extract_linters_from(options.fetch(:excluded_linters, []))
|
39
39
|
|
40
40
|
# After filtering out explicitly included/excluded linters, only include
|
41
41
|
# linters which are enabled in the configuration
|
@@ -51,18 +51,19 @@ module SlimLint
|
|
51
51
|
@source_lines = []
|
52
52
|
@source_map = {}
|
53
53
|
@line_count = 0
|
54
|
+
@dummy_puts_count = 0
|
54
55
|
end
|
55
56
|
|
56
57
|
on [:html, :doctype] do |sexp|
|
57
|
-
|
58
|
+
append_dummy_puts(sexp)
|
58
59
|
end
|
59
60
|
|
60
61
|
on [:html, :tag] do |sexp|
|
61
|
-
|
62
|
+
append_dummy_puts(sexp)
|
62
63
|
end
|
63
64
|
|
64
65
|
on [:static] do |sexp|
|
65
|
-
|
66
|
+
append_dummy_puts(sexp)
|
66
67
|
end
|
67
68
|
|
68
69
|
on [:dynamic] do |sexp|
|
@@ -94,5 +95,10 @@ module SlimLint
|
|
94
95
|
@source_map[@line_count] = original_line + index
|
95
96
|
end
|
96
97
|
end
|
98
|
+
|
99
|
+
def append_dummy_puts(sexp)
|
100
|
+
append("_slim_lint_puts_#{@dummy_puts_count}", sexp)
|
101
|
+
@dummy_puts_count += 1
|
102
|
+
end
|
97
103
|
end
|
98
104
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubocop'
|
2
|
+
require 'rubocop/ast_node/builder'
|
2
3
|
require 'parser/current'
|
3
4
|
|
4
5
|
module SlimLint
|
@@ -10,7 +11,7 @@ module SlimLint
|
|
10
11
|
class RubyParser
|
11
12
|
# Creates a reusable parser.
|
12
13
|
def initialize
|
13
|
-
@builder = ::
|
14
|
+
@builder = ::RuboCop::Node::Builder.new
|
14
15
|
@parser = ::Parser::CurrentRuby.new(@builder)
|
15
16
|
end
|
16
17
|
|
data/lib/slim_lint/sexp.rb
CHANGED
@@ -84,11 +84,12 @@ module SlimLint
|
|
84
84
|
output << "\n"
|
85
85
|
output += indentation
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
output +=
|
88
|
+
if nested_sexp.is_a?(SlimLint::Sexp)
|
89
|
+
nested_sexp.display(depth + 1)
|
90
|
+
else
|
91
|
+
nested_sexp.inspect
|
92
|
+
end
|
92
93
|
|
93
94
|
# Add trailing comma unless this is the last item
|
94
95
|
output += ',' if index < length - 1
|
data/lib/slim_lint/utils.rb
CHANGED
@@ -57,9 +57,9 @@ module SlimLint
|
|
57
57
|
# inclusion
|
58
58
|
# @yieldreturn [Boolean] whether to include the item
|
59
59
|
# @return [Integer]
|
60
|
-
def count_consecutive(items, offset = 0
|
60
|
+
def count_consecutive(items, offset = 0)
|
61
61
|
count = 1
|
62
|
-
count += 1 while (offset + count < items.count) &&
|
62
|
+
count += 1 while (offset + count < items.count) && yield(items[offset + count])
|
63
63
|
count
|
64
64
|
end
|
65
65
|
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slim
|
@@ -24,20 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rubocop
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
47
|
+
version: 0.36.0
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
54
|
+
version: 0.36.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: sysexits
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +102,7 @@ executables:
|
|
88
102
|
extensions: []
|
89
103
|
extra_rdoc_files: []
|
90
104
|
files:
|
105
|
+
- LICENSE.md
|
91
106
|
- bin/slim-lint
|
92
107
|
- config/default.yml
|
93
108
|
- lib/slim_lint.rb
|
@@ -157,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
172
|
version: '0'
|
158
173
|
requirements: []
|
159
174
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.4.
|
175
|
+
rubygems_version: 2.4.5.1
|
161
176
|
signing_key:
|
162
177
|
specification_version: 4
|
163
178
|
summary: Slim template linting tool
|