Replace @provides with @providesModule
Reviewed By: davidaurelio Differential Revision: D4494624 fbshipit-source-id: 192cc77126a99b3a3baeb806ed605c2194c4713a
This commit is contained in:
parent
0ed31eb3d6
commit
d82f2553fb
|
@ -18,7 +18,7 @@
|
|||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* @provides ListViewPagingExample
|
||||
* @providesModule ListViewPagingExample
|
||||
* @flow
|
||||
*/
|
||||
'use strict';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @provides Array.es6
|
||||
* @providesModule Array.es6
|
||||
* @polyfill
|
||||
*/
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @provides Array.prototype.es6
|
||||
* @providesModule Array.prototype.es6
|
||||
* @polyfill
|
||||
*/
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @provides Number.es6
|
||||
* @providesModule Number.es6
|
||||
* @polyfill
|
||||
*/
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @provides Object.es7
|
||||
* @providesModule Object.es7
|
||||
* @polyfill
|
||||
*/
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @provides String.prototype.es6
|
||||
* @providesModule String.prototype.es6
|
||||
* @polyfill
|
||||
*/
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @provides console
|
||||
* @providesModule console
|
||||
* @polyfill
|
||||
* @nolint
|
||||
*/
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @provides Object.es6
|
||||
* @providesModule Object.es6
|
||||
* @polyfill
|
||||
*/
|
||||
|
||||
|
|
|
@ -184,10 +184,11 @@ class Module {
|
|||
// modules, such as react-haste, fbjs-haste, or react-native or with non-dependency,
|
||||
// project-specific code that is using @providesModule.
|
||||
const moduleDocBlock = docblock.parseAsObject(docBlock);
|
||||
const provides = moduleDocBlock.providesModule || moduleDocBlock.provides;
|
||||
const providesModule = moduleDocBlock.providesModule;
|
||||
|
||||
const id = provides && !this._depGraphHelpers.isNodeModulesDir(this.path)
|
||||
? /^\S+/.exec(provides)[0]
|
||||
const id =
|
||||
providesModule && !this._depGraphHelpers.isNodeModulesDir(this.path)
|
||||
? /^\S+/.exec(providesModule)[0]
|
||||
: undefined;
|
||||
return {id, moduleDocBlock};
|
||||
}
|
||||
|
|
|
@ -125,34 +125,6 @@ describe('Module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('@provides annotations', () => {
|
||||
beforeEach(() => {
|
||||
mockIndexFile(source.replace(/@providesModule/, '@provides'));
|
||||
});
|
||||
|
||||
it('extracts the module name from the header if it has a @provides annotation', () =>
|
||||
module.getName().then(name => expect(name).toEqual(moduleId))
|
||||
);
|
||||
|
||||
it('identifies the module as haste module', () =>
|
||||
module.isHaste().then(isHaste => expect(isHaste).toBe(true))
|
||||
);
|
||||
|
||||
it('does not transform the file in order to access the name', () => {
|
||||
const transformCode =
|
||||
jest.genMockFn().mockReturnValue(Promise.resolve());
|
||||
return createModule({transformCode}).getName()
|
||||
.then(() => expect(transformCode).not.toBeCalled());
|
||||
});
|
||||
|
||||
it('does not transform the file in order to access the haste status', () => {
|
||||
const transformCode =
|
||||
jest.genMockFn().mockReturnValue(Promise.resolve());
|
||||
return createModule({transformCode}).isHaste()
|
||||
.then(() => expect(transformCode).not.toBeCalled());
|
||||
});
|
||||
});
|
||||
|
||||
describe('no annotation', () => {
|
||||
beforeEach(() => {
|
||||
mockIndexFile('arbitrary(code);');
|
||||
|
|
|
@ -112,14 +112,14 @@ function getFileDocBlock(commentsForFile) {
|
|||
inCopyrightBlock = true;
|
||||
}
|
||||
|
||||
var hasProvides = !!line.match(/^\s*\*\s+@provides/);
|
||||
var hasProvidesModule = !!line.match(/^\s*\*\s+@providesModule/);
|
||||
var hasFlow = !!line.match(/^\s*\*\s+@flow/);
|
||||
|
||||
if (hasFlow || hasProvides) {
|
||||
if (hasFlow || hasProvidesModule) {
|
||||
inCopyrightBlock = false;
|
||||
}
|
||||
|
||||
return !inCopyrightBlock && !hasFlow && !hasProvides;
|
||||
return !inCopyrightBlock && !hasFlow && !hasProvidesModule;
|
||||
});
|
||||
docblock = filteredLines.join('\n');
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue