Skip to content

Commit

Permalink
FSharpLint.Core: implement new rule
Browse files Browse the repository at this point in the history
  • Loading branch information
tehraninasab authored and webwarrior-ws committed Dec 21, 2023
1 parent 8d398de commit 99385b5
Showing 1 changed file with 36 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,44 @@ open FSharpLint.Framework.Ast
open FSharpLint.Framework.Rules



let runner (args:AstNodeRuleParams) =
printfn "AstNode: %A" args.AstNode
let error =
match args.AstNode with
| AstNode.Expression (SynExpr.LetOrUse (isRecursive, isUse, bindings, body, range)) ->
match bindings with
| head ->
()
| _ ->
()
let parents = args.GetParents 5
printfn "%A" parents
Array.empty
// checkRecursiveAsyncFunction args range expr parents
| _ -> Array.empty

printfn "----------------"

let mutable error = Array.empty
let mutable idents = List.empty<string>
match args.AstNode with
| AstNode.Expression (SynExpr.LetOrUse (isRecursive, isUse, bindings, body, range)) ->
match bindings.[0] with
| SynBinding(synAccessOption, synBindingKind, mustInline, isMutable, synAttributeLists, preXmlDoc, synValData, headPat, synBindingReturnInfoOption, synExpr, range, debugPointAtBinding) ->
match headPat with
| SynPat.Named(synPat, ident, isSelfIdentifier, synAccessOption, range) ->
idents <- List.append idents [ident.idText]
| _ ->
()

match body with
| SynExpr.Sequential(debugPointAtSequential, isTrueSeq, synExpr, expr2, range) ->
match synExpr with
| SynExpr.App(exprAtomicFlag, isInfix, funcExpr, argExpr, range) ->

match argExpr with
| SynExpr.Ident ident ->
if (List.contains ident.idText idents) then
error <- ({
Range = range
Message = String.Format(Resources.GetString ("RulesUsedUnderscorePrefixedElements"))
SuggestedFix = None
TypeChecks = []
} |> Array.singleton)
else
()
| _ ->
()
| _ ->
()
| _ ->
()
| _ -> ()

error

let rule =
Expand Down

0 comments on commit 99385b5

Please sign in to comment.