{"id":18773028,"url":"https://github.com/maincode-org/eslint-rule-dev-toolkit","last_synced_at":"2025-10-08T03:16:33.486Z","repository":{"id":42626876,"uuid":"431781814","full_name":"maincode-org/eslint-rule-dev-toolkit","owner":"maincode-org","description":"A toolkit of awesome helpers for developing advanced ESLint rules with ease!","archived":false,"fork":false,"pushed_at":"2022-09-11T11:28:49.000Z","size":309,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T09:06:25.013Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maincode-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-25T09:14:49.000Z","updated_at":"2023-02-14T11:35:42.000Z","dependencies_parsed_at":"2022-09-14T09:10:41.006Z","dependency_job_id":null,"html_url":"https://github.com/maincode-org/eslint-rule-dev-toolkit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maincode-org%2Feslint-rule-dev-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maincode-org%2Feslint-rule-dev-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maincode-org%2Feslint-rule-dev-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maincode-org%2Feslint-rule-dev-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maincode-org","download_url":"https://codeload.github.com/maincode-org/eslint-rule-dev-toolkit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688570,"owners_count":21145766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T19:32:23.661Z","updated_at":"2025-10-08T03:16:28.452Z","avatar_url":"https://github.com/maincode-org.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESLint Rule Development Toolkit\nA library of awesome helpers for developing advanced ESLint rules with ease! Currently, only includes one central piece of functionality; tracing values mid-analysis.\n\nThe aim so to provide a more complete and sound analysis whenever identifiers are considered in ESLint rules.\n\n## Getting started\n\nBelow is a description of the details to consider when using the function.\n\n## The Trace Value algorithm\n### Function parameters\nThe function takes three parameters; an AST node, a rule context, and optionally a verifier function.\nBecause this function is a helper function for rule developers, the AST node provided by the user, is whatever node the rule developer wants to check.\nThe rule context is just the context of the rule being developed.\nThe verifier function is a function that describes a recipe of how to verify the node/deem the node safe.\n\n### Function return\nTraceValue returns an object containing a result and a trace. The result includes a boolean and an AST node.\nThis node is the determining node from the process of verifying the provided node.\nThe boolean describes whether the AST node can be deemed safe or not.\n\nThe `nodeComponentTrace` field is a representation of all the value nodes that were visited in the process of verifying the provided node.\nAs a result of this approach, whenever the algorithm visits a node that can not be verified, the `nodeComponentTrace` will only include the nodes related to this unverified node.\nIn cases where there are no unverified nodes, the `nodeComponentTrace` includes all visited nodes.\n\n### The type of the returned object:\n```typescript\n{ \n  result: { \n    isVerified: boolean;\n    determiningNode: TSESTree.Node;\n  }\n  nodeComponentTrace: ITraceNode[];\n}\n```\n\n## TraceValue examples\n### Determining the value of an object property reference\n\nIn the ESLint rule:\n```javascript\n//... We locate an ObjectExpression node, where we want to analyse the Literal's value of property a.\nconst result = traceValue(Node, RuleContext, (node) =\u003e node.type === \"Literal\");\n\nif(!result.isVerified) Context.report(node, \"Failed to determine value of object.a\");\nelse if(result.determiningNode.value !== \"the exact value i want\") Context.report(node, \"Object.a must be the exact value i want.\");\n```\n\nJavascript source code:\n```javascript\nconst obj_001 = { a: \"This is a string\", b: \"Another string\" };\n```\nIn this example, the rule reports \"Object.a must be the exact value I want.\", on the node `obj_001`;\n\nJavascript source code:\n```javascript\nconst obj_002 = { a: fetch('https://evilcorp.com/hacky-hacky'), a: \"Safe string\" };\n```\nIn this example, the rule reports \"Failed to determine value of object.a\", on the node `obj_002`.\n\n### Analyzing the node identifier\nIf you want to analyze the identifier of the node instead of the value, you can use the AST returned from traceValue to analyze it yourself.\nFor example if you wanted to make a rule that checks if all variable names are ice cream flavors, you can traverse the returned AST yourself, and do the checking.\n\n## Test suite\n### Approach\nThe test files in the test suite are separated based on different types of programming constructs.\nThe traceValue algorithm might be able to correctly analyze additional programming constructs beyond what is present in these tests.\nAccompanying the test files are target files containing Javascript source code.\nThese target files include different test cases for each type of programming construct.\nThe tests in the test files are simply testing the result of tracing some value in a target file, for example `arr_001`, which is array case 1.\n\n#### LIMITATION keyword\nThere are a number of tests prefixed with \"LIMITATION\" keyword, which means the result of the tracing is lackluster.\nFailing \"LIMITATION\" tests are not necessarily an issue. It could be due to an extension of functionality.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaincode-org%2Feslint-rule-dev-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaincode-org%2Feslint-rule-dev-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaincode-org%2Feslint-rule-dev-toolkit/lists"}