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

Review file and folder structure casing and relationship #38

Closed
rochdev opened this issue Jun 18, 2019 · 4 comments
Closed

Review file and folder structure casing and relationship #38

rochdev opened this issue Jun 18, 2019 · 4 comments
Labels
feature-request up-for-grabs Good for taking. Extra help will be provided by maintainers
Milestone

Comments

@rochdev
Copy link
Member

rochdev commented Jun 18, 2019

Is your feature request related to a problem? Please describe.

Right now it's not easy to correlate a file with its content. A usual TypeScript project has the name of the file match what it exports. For example: https://github.com/microsoft/TypeScript-Node-Starter/tree/master/src

Describe the solution you'd like

There should be a TSLint rule if possible with the below rules:

  • Class and interfaces files should be UpperCamelCase.
  • Singleton files should be name like what they export (usually camelCase).
  • Files with multiple exports should be kebab-case with a description of the group of exports they represent.
  • I'm not sure what the standard is for folders, but I would use the as the above (kebab-case in this proposal).
@draffensperger
Copy link
Contributor

Class and interfaces files should be UpperCamelCase.

Yes - this is the class-name rule that is already enforced in the packages via gts

Singleton files should be name like what they export (usually camelCase).
I like this though I'm not sure how to
Files with multiple exports should be kebab-case with a description of the group of exports they represent.

I'm fine with enforcing camelCase for filenames. The TS book style guide concurs and the TypeScript repo itself uses it. We can enforce that via the file-name-casing rule. Google uses snake_case.ts internally for TS filenames and folders, which is where OpenCensus got it I believe, but snakeCase seems to be more of the community standard so we should go with that.

We should be able to use the export-name rule to enforce this from the tslint-microsoft-contrib repo, which only enforces the rule for files with single exports, and use reviewer judgment to make sure multi-export filenames have good names.

I'm not sure what the standard is for folders, but I would use the as the above (kebab-case in this proposal).

The TypeScript repo itself seems to use camelCase for folders, which would make it consistent with file names, but I'm fine with kebab-case for folders. I think camelCase feels a bit more Window-y and snake_case a bit more Unix-y, but modern systems can handle both.

@mayurkale22
Copy link
Member

Yes - this is the class-name rule that is already enforced in the packages via gts

+1

What should be the TSLint rule for name of the test files? (either index.test.ts or test-index.ts or test_index.ts)

@rochdev
Copy link
Member Author

rochdev commented Jun 19, 2019

@draffensperger I'm not sure your suggestions are the same as what I described above. Let me provide a few examples of what I meant just to make sure.

Class example: Entry.ts
Singleton/function example: randomBytes.ts
Utilities example: some-util.ts
Folder example: /distributed-context/

This makes it easy to know what is the content of the file. The most important part is the files where the file name matches the export. I don't have a strong opinion for folders or utilities names. kebab-case and snake_case are easier to read, but camelCase would be more consistent.

Is this something these TSLint rules can handle? If not I'm fine to revisit this with something that can be enforced as it will make standardizing this easier.

@mayurkale22 mayurkale22 added this to the Configs milestone Jun 21, 2019
@rochdev rochdev mentioned this issue Jul 5, 2019
@mayurkale22 mayurkale22 added the up-for-grabs Good for taking. Extra help will be provided by maintainers label Aug 19, 2019
@legendecas
Copy link
Member

I believe our code bases are following such rules and this issue can be closed.

pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this issue Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request up-for-grabs Good for taking. Extra help will be provided by maintainers
Projects
None yet
Development

No branches or pull requests

4 participants