question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filename and directory structure

See original GitHub issue

I have a question about the naming convention, the styleguide specifies that if the file exports a single class, the name of the file should be the name of the class. (see https://github.com/airbnb/javascript#naming--filename-matches-export)

So something like this:

import CheckBox from './CheckBox';

What about the directory structure? Is there any preference? Because, these 2 structures are good based on the styleguide, but the import syntax will be different.

├── src
│   ├── CheckBox
│   │   ├── index.js
│   │   ├── CheckBox.js
import CheckBox from './CheckBox';
├── src
│   ├── checkbox
│   │   ├── index.js
│   │   ├── CheckBox.js
import CheckBox from './checkbox';

Does airbnb have a preference? For internal component, I find it ok to have import with capital letters, but in an external library, it doesn’t seem very common to have import CheckBox from 'component-lib/CheckBox';

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
ljharbcommented, Apr 9, 2016

Yes, ideally the directory name would match the name of the default export of index.js. Perhaps some tweaking of https://github.com/airbnb/javascript#naming--filename-matches-export is needed.

1reaction
tleunencommented, Apr 9, 2016

Great, thanks! You can close the ticket, or leave it open as a reminder to tweak the guide.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File naming and structure - Research Data Management at ...
File naming best practices: · Files should be named consistently · File names should be short but descriptive (<25 characters) (Briney, 2015) ...
Read more >
Filename - Wikipedia
A filename or file name is a name used to uniquely identify a computer file in a directory structure. Different file systems impose...
Read more >
preserving the original sub-folder and filename
The PreservedFilename tag is the most common place to store an original filename. You could store the directory there as well if you...
Read more >
Chapter 4. Organizing and Naming Files and Folders - O'Reilly
The directory structure is the organization of files into a hierarchy of folders. It should be stable and scalable; ... Working File Directory...
Read more >
File and Directory Names: File, Path, Paths (Java Files Tutorial)
io.File . A file object can represent a filename, a directory name, a relative file or directory path, or an absolute file or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found