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

Add linting rule for site prism pages #14

Open
AndrewSwerlick opened this issue Mar 14, 2023 · 0 comments
Open

Add linting rule for site prism pages #14

AndrewSwerlick opened this issue Mar 14, 2023 · 0 comments

Comments

@AndrewSwerlick
Copy link
Contributor

AndrewSwerlick commented Mar 14, 2023

To make site prism pages more discoverable, I propose we have a linter rule which enforces that the module namespaces for a site prism page matches the value passed to set_url.

The general rules would be something like

  • Each static segment of the url that's not the final segment should have a module declaration, in the same order they appear in the url
  • Dynamic segments of the url are ignored
  • If the last segment of a url is dynamic, then the class name can be anything as long as it ends in Page
  • If the last segment of the url is not dynamic, then it needs to be <CamelCasedSegment>Page

Here are some thoughts on what should pass and fail

Good

class UsersPage
  set_url "users"
end
module Users
  class ShowPage
    set_url "users/{id}"
  end
end
module Users
  class EditPage
    set_url "users/{id}/edit"
  end
end
module Users
  class NewPage
    set_url "users/{id}/new"
  end
end
module Users
  class PostsPage
    set_url "users/{id}/posts"
  end
end

Bad

class UsersPostsPage
  set_url "users/{id}/posts"
end
class UserPage
    set_url "users/{id}"
end  
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