diff --git a/README.md b/README.md index 39ce51f1..c07a087e 100644 --- a/README.md +++ b/README.md @@ -2337,24 +2337,39 @@ Other Style Guides ``` - - [22.6](#naming--filename-matches-export) If your file exports a single class, your filename should be exactly the name of the class. + - [22.6](#naming--filename-matches-export) A base filename should exactly match the name of its default export. ```javascript - // file contents + // file 1 contents class CheckBox { // ... } export default CheckBox; + // file 2 contents + export default function fortyTwo() { return 42; } + + // file 3 contents + export default function insideDirectory() {} + // in some other file // bad - import CheckBox from './checkBox'; + import CheckBox from './checkBox'; // PascalCase import/export, camelCase filename + import FortyTwo from './FortyTwo'; // PascalCase import/filename, camelCase export + import InsideDirectory from './InsideDirectory'; // PascalCase import/filename, camelCase export // bad - import CheckBox from './check_box'; + import CheckBox from './check_box'; // PascalCase import/export, snake_case filename + import forty_two from './forty_two'; // snake_case import/filename, camelCase export + import inside_directory from './inside_directory'; // snake_case import, camelCase export + import index from './inside_directory/index'; // requiring the index file explicitly + import insideDirectory from './insideDirectory/index'; // requiring the index file explicitly // good - import CheckBox from './CheckBox'; + import CheckBox from './CheckBox'; // PascalCase export/import/filename + import fortyTwo from './fortyTwo'; // camelCase export/import/filename + import insideDirectory from './insideDirectory'; // camelCase export/import/directory name/implicit "index" + // ^ supports both insideDirectory.js and insideDirectory/index.js ``` @@ -2368,7 +2383,7 @@ Other Style Guides ``` - - [22.8](#naming--PascalCase-singleton) Use PascalCase when you export a singleton / function library / bare object. + - [22.8](#naming--PascalCase-singleton) Use PascalCase when you export a constructor / class / singleton / function library / bare object. ```javascript const AirbnbStyleGuide = {