Stencil Style Guide
This is a component style guide created and enforced internally by the core team of Stencil, for the purpose of standardizing Stencil components. This should only be used as a reference for other teams in creating their own style guides. Feel free to modify to your team's own preference.
注記
In order to enforce this (or your team's) style guide, we recommend leveraging a static analysis tool like ESLint. @stencil-community/eslint-plugin provides rules specifically for writing Stencil components.
注記
This guide once recommended TSLint as a static analysis tool. TSLint has been deprecated by its maintaining organization in favor of ESLint and is no longer recommended by the Stencil team.
File structure
- One component per file.
- One component per directory. Though it may make sense to group similar components into the same directory, we've found it's easier to document components when each one has its own directory.
- Implementation (.tsx) and styles of a component should live in the same directory.
Example from ionic-core:
├── my-card
│ ├── my-card.ios.css
│ ├── my-card.md.css
│ ├── my-card.css
│ ├── my-card.tsx
│ └── test
│ └── basic
│ ├── e2e.js
│ └── index.html
├── my-card-content
│ ├── my-card-content.ios.css
│ ├── my-card-content.md.css