Skip to content

Commit

Permalink
solution prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Mar 29, 2024
1 parent 3ef4699 commit 92bcf6b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/linter/block_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,24 @@ type blockLinter struct {
quickfix *QuickFixGenerator
}

func (b *blockLinter) checkStringInterpolationDeprecated(str *ir.Encapsed) {
for _, item := range str.Parts {
variable, ok := item.(*ir.SimpleVar)
if ok {
if variable.IdentifierTkn.Value[0] != 36 { // 36 is $
b.report(str, LevelWarning, "stringInterpolationDeprecated", "use {$variable} instead ${variable}}")
break
}
}
}
}

func (b *blockLinter) enterNode(n ir.Node) {
switch n := n.(type) {

case *ir.Encapsed:
b.checkStringInterpolationDeprecated(n)

case *ir.Assign:
b.checkAssign(n)

Expand Down
9 changes: 9 additions & 0 deletions src/linter/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,15 @@ g();`,
}`,
},

{
Name: "stringInterpolationDeprecated",
Default: true,
Quickfix: false,
Comment: `Report deprecated string interpolation style`,
Before: `${variable}`,
After: `{$variable}`,
},

{
Name: "misspellName",
Default: true,
Expand Down

0 comments on commit 92bcf6b

Please sign in to comment.