Skip to content

Commit

Permalink
Revert "Add support for linting ECR files (#536)" (#540)
Browse files Browse the repository at this point in the history
This reverts commit 371414e.
  • Loading branch information
Sija authored Jan 15, 2025
1 parent 371414e commit 262f57d
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 61 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ In this example we define default globs and exclude `src/compiler` folder:
``` yaml
Globs:
- "**/*.cr"
- "**/*.ecr"
- "!lib"
Excluded:
Expand Down
26 changes: 0 additions & 26 deletions spec/ameba/source_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,5 @@ module Ameba
CRYSTAL
end
end

if Ameba.ecr_supported?
describe "#ast" do
it "parses an ECR file" do
source = Source.new <<-ECR, "filename.ecr"
hello <%= "world" %>
ECR

source.ast.to_s.should eq(<<-CRYSTAL)
__str__ << "hello "
("world").to_s(__str__)
CRYSTAL
end

it "raises an exception when ECR parsing fails" do
source = Source.new <<-ECR, "filename.ecr"
hello <%= "world" >
ECR

expect_raises(Crystal::SyntaxException) do
source.ast
end
end
end
end
end
end
4 changes: 0 additions & 4 deletions src/ameba.cr
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,4 @@ module Ameba
def run(config = Config.load)
Runner.new(config).run
end

def self.ecr_supported? : Bool
{{ compare_versions(Crystal::VERSION, "1.15.0") >= 0 }}
end
end
7 changes: 1 addition & 6 deletions src/ameba/config.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require "semantic_version"
require "yaml"
require "ecr/processor"
require "./glob_utils"

# A configuration entry for `Ameba::Runner`.
Expand Down Expand Up @@ -63,10 +62,6 @@ class Ameba::Config
!lib
)

if Ameba.ecr_supported?
DEFAULT_GLOBS << "**/*.ecr"
end

getter rules : Array(Rule::Base)
property severity = Severity::Convention

Expand Down Expand Up @@ -172,7 +167,7 @@ class Ameba::Config
# ```
# config = Ameba::Config.load
# config.sources # => list of default sources
# config.globs = ["**/*.cr", "**/*.ecr"]
# config.globs = ["**/*.cr"]
# config.excluded = ["spec"]
# config.sources # => list of sources pointing to files found by the wildcards
# ```
Expand Down
9 changes: 1 addition & 8 deletions src/ameba/glob_utils.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ module Ameba
def expand(globs)
globs
.flat_map do |glob|
if File.directory?(glob)
glob += "/**/*.cr"

if Ameba.ecr_supported?
glob += "/**/*.ecr"
end
end

glob += "/**/*.cr" if File.directory?(glob)
Dir[glob]
end
.uniq!
Expand Down
16 changes: 0 additions & 16 deletions src/ameba/source.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,6 @@ module Ameba
# source.ast
# ```
getter ast : Crystal::ASTNode do
code = @code

if Ameba.ecr_supported? && @path.ends_with?(".ecr")
begin
code = ECR.process_string(code, @path)
rescue ex : ECR::Lexer::SyntaxException
# Need to rescue to add the filename
raise Crystal::SyntaxException.new(
ex.message,
ex.line_number,
ex.column_number,
@path
)
end
end

Crystal::Parser.new(code)
.tap(&.wants_doc = true)
.tap(&.filename = path)
Expand Down

0 comments on commit 262f57d

Please sign in to comment.