Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split checker into multiple files #15

Open
mraak opened this issue Feb 16, 2019 · 0 comments
Open

Split checker into multiple files #15

mraak opened this issue Feb 16, 2019 · 0 comments

Comments

@mraak
Copy link
Collaborator

mraak commented Feb 16, 2019

For the purposes of better readability, easier branching merging and easier developer onboarding, it would be useful to split the checker.js into multiple files.

For example,

var collectTypesVisitors = {
	TaggedTemplateExpression(path) {
		if (T.isIdentifier(path.node.tag)) {
			let tagName = path.node.tag.name;
			if (recognizedTypeIDs.includes(tagName)) {
				nodeTypes.set(path.node,{ tagged: tagName, });
			}
		}
	},
	TemplateLiteral(path) {
		if (T.isTaggedTemplateExpression(path.parent)) {
			let parentType = nodeTypes.get(path.parent);
			if (parentType) {
				nodeTypes.set(path.node,{ ...parentType, });
			}
			else {
				nodeTypes.set(path.node,{ inferred: "unknown", });
			}
		}
		else {
			nodeTypes.set(path.node,{ inferred: "string", });
		}
	},

//... etc...
}

could be split on a "per visitor type" basis.

var collectTypesVisitors = {
  TaggedTemplateExpression: require('checkTaggedTemplateExpression'),
  TemplateLiteral: require('checkTemplateLiteral'),
}

Or something similar.

That way for example, a developer or a group of developers could focus on documentation, tests, and code only related to one visitor type, without ever affecting the rest of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant