diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2017-10-09 10:42:20 +0000 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2017-10-09 10:42:20 +0000 |
commit | 30e0262813aff896189e1c2327a6b951ce4d34ad (patch) | |
tree | b60ef6de17b6f06eb1bdffe26da30732dd886ed9 /doc/development | |
parent | 8af29c214ce0ac382f85a0e37a2106138ed13f6d (diff) | |
download | gitlab-ce-30e0262813aff896189e1c2327a6b951ce4d34ad.tar.gz |
Make naming imports more clearwinh-clarify-naming-imports-docswinh-clarify-naming-imports
Diffstat (limited to 'doc/development')
-rw-r--r-- | doc/development/fe_guide/style_guide_js.md | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/doc/development/fe_guide/style_guide_js.md b/doc/development/fe_guide/style_guide_js.md index 77ae6d2a0ea..10f4c5a0902 100644 --- a/doc/development/fe_guide/style_guide_js.md +++ b/doc/development/fe_guide/style_guide_js.md @@ -88,16 +88,31 @@ followed by any global declarations, then a blank newline prior to any imports o 1. Use ES module syntax to import modules ```javascript // bad - require('foo'); + const SomeClass = require('some_class'); // good - import Foo from 'foo'; + import SomeClass from 'some_class'; // bad - module.exports = Foo; + module.exports = SomeClass; // good - export default Foo; + export default SomeClass; + ``` + + Import statements are following usual naming guidelines, for example object literals use camel case: + + ```javascript + // some_object file + export default { + key: 'value', + }; + + // bad + import ObjectLiteral from 'some_object'; + + // good + import objectLiteral from 'some_object'; ``` 1. Relative paths: when importing a module in the same directory, a child @@ -285,6 +300,13 @@ A forEach will cause side effects, it will be mutating the array being iterated. 1. **Extensions**: Use `.vue` extension for Vue components. 1. **Reference Naming**: Use camelCase for their instances: ```javascript + // bad + import CardBoard from 'cardBoard' + + components: { + CardBoard: + }; + // good import cardBoard from 'cardBoard' |