Skip to content

Commit edd25f5

Browse files
authored
Add JSDoc Validation (parse-community#1240)
* Add JSDoc Validator * fix build * Make globals private * remove warnings * fix tests
1 parent 188074f commit edd25f5

40 files changed

+1324
-1024
lines changed

.eslintrc.json

+66-31
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,69 @@
11
{
2-
"root": true,
3-
"extends": "eslint:recommended",
4-
"env": {
5-
"node": true,
6-
"es6": true
7-
},
8-
"parser": "babel-eslint",
9-
"globals": {
10-
"wx": true
11-
},
12-
"plugins": [
13-
"flowtype"
2+
"root": true,
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:jsdoc/recommended"
6+
],
7+
"env": {
8+
"node": true,
9+
"es6": true
10+
},
11+
"parser": "babel-eslint",
12+
"globals": {
13+
"wx": true
14+
},
15+
"plugins": [
16+
"flowtype",
17+
"jsdoc"
18+
],
19+
"parserOptions": {
20+
"ecmaVersion": 6,
21+
"sourceType": "module"
22+
},
23+
"rules": {
24+
"indent": ["error", 2],
25+
"linebreak-style": ["error", "unix"],
26+
"no-trailing-spaces": 2,
27+
"eol-last": 2,
28+
"space-in-parens": ["error", "never"],
29+
"no-multiple-empty-lines": 1,
30+
"prefer-const": "error",
31+
"space-infix-ops": "error",
32+
"no-useless-escape": "off",
33+
"no-var": "error",
34+
"no-console": 0,
35+
"no-prototype-builtins": "off",
36+
"require-atomic-updates": "off",
37+
"jsdoc/require-jsdoc": 0,
38+
"jsdoc/require-returns-description": 0,
39+
"jsdoc/require-param-description": 0,
40+
"jsdoc/require-property-description": 0,
41+
"jsdoc/require-param-type": 0,
42+
"jsdoc/check-param-names": [
43+
"error",
44+
{
45+
"allowExtraTrailingParamDocs": true
46+
}
1447
],
15-
"parserOptions": {
16-
"ecmaVersion": 6,
17-
"sourceType": "module"
18-
},
19-
"rules": {
20-
"indent": ["error", 2],
21-
"linebreak-style": ["error", "unix"],
22-
"no-trailing-spaces": 2,
23-
"eol-last": 2,
24-
"space-in-parens": ["error", "never"],
25-
"no-multiple-empty-lines": 1,
26-
"prefer-const": "error",
27-
"space-infix-ops": "error",
28-
"no-useless-escape": "off",
29-
"no-var": "error",
30-
"no-console": 0,
31-
"no-prototype-builtins": "off",
32-
"require-atomic-updates": "off"
33-
}
48+
"jsdoc/check-tag-names": [
49+
"error",
50+
{
51+
"definedTags": [
52+
"flow",
53+
"flow-weak"
54+
]
55+
}
56+
],
57+
"jsdoc/no-undefined-types": [
58+
"error",
59+
{
60+
"definedTypes": [
61+
"AuthProvider",
62+
"AsyncStorage",
63+
"LocalDatastoreController",
64+
"Parse"
65+
]
66+
}
67+
]
68+
}
3469
}

integration/test/clear.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const Parse = require('../../node');
55
* Calls /clear route in integration/test/server.js
66
*
77
* @param {boolean} fast set to true if it's ok to just drop objects and not indexes.
8+
* @returns {Promise} A promise that is resolved when database is deleted.
89
*/
910
module.exports = function(fast = true) {
1011
return Parse._ajax('GET', `http://localhost:1337/clear/${fast}`, '');

package-lock.json

+41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"cross-env": "7.0.2",
5757
"eslint": "6.8.0",
5858
"eslint-plugin-flowtype": "5.1.2",
59+
"eslint-plugin-jsdoc": "30.7.3",
5960
"express": "4.17.1",
6061
"gulp": "4.0.2",
6162
"gulp-babel": "8.0.0",

src/Analytics.js

+30-30
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,36 @@ import CoreManager from './CoreManager';
2121
*/
2222

2323
/**
24-
* Tracks the occurrence of a custom event with additional dimensions.
25-
* Parse will store a data point at the time of invocation with the given
26-
* event name.
27-
*
28-
* Dimensions will allow segmentation of the occurrences of this custom
29-
* event. Keys and values should be {@code String}s, and will throw
30-
* otherwise.
31-
*
32-
* To track a user signup along with additional metadata, consider the
33-
* following:
34-
* <pre>
35-
* var dimensions = {
36-
* gender: 'm',
37-
* source: 'web',
38-
* dayType: 'weekend'
39-
* };
40-
* Parse.Analytics.track('signup', dimensions);
41-
* </pre>
42-
*
43-
* There is a default limit of 8 dimensions per event tracked.
44-
*
45-
* @method track
46-
* @name Parse.Analytics.track
47-
* @param {String} name The name of the custom event to report to Parse as
48-
* having happened.
49-
* @param {Object} dimensions The dictionary of information by which to
50-
* segment this event.
51-
* @return {Promise} A promise that is resolved when the round-trip
52-
* to the server completes.
53-
*/
24+
* Tracks the occurrence of a custom event with additional dimensions.
25+
* Parse will store a data point at the time of invocation with the given
26+
* event name.
27+
*
28+
* Dimensions will allow segmentation of the occurrences of this custom
29+
* event. Keys and values should be {@code String}s, and will throw
30+
* otherwise.
31+
*
32+
* To track a user signup along with additional metadata, consider the
33+
* following:
34+
* <pre>
35+
* var dimensions = {
36+
* gender: 'm',
37+
* source: 'web',
38+
* dayType: 'weekend'
39+
* };
40+
* Parse.Analytics.track('signup', dimensions);
41+
* </pre>
42+
*
43+
* There is a default limit of 8 dimensions per event tracked.
44+
*
45+
* @function track
46+
* @name Parse.Analytics.track
47+
* @param {string} name The name of the custom event to report to Parse as
48+
* having happened.
49+
* @param {object} dimensions The dictionary of information by which to
50+
* segment this event.
51+
* @returns {Promise} A promise that is resolved when the round-trip
52+
* to the server completes.
53+
*/
5454
export function track(
5555
name: string,
5656
dimensions: { [key: string]: string }

src/AnonymousUtils.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
*
99
* @flow-weak
1010
*/
11+
1112
import ParseUser from './ParseUser';
12-
const uuidv4 = require('uuid/v4');
1313
import type { RequestOptions } from './RESTController';
14+
const uuidv4 = require('uuid/v4');
1415

1516
let registered = false;
1617

@@ -38,18 +39,19 @@ let registered = false;
3839
* <li>Service linking (e.g. Facebook, Twitter) will convert the anonymous user
3940
* into a standard user by linking it to the service.</li>
4041
* </ul>
42+
*
4143
* @class Parse.AnonymousUtils
4244
* @static
4345
*/
4446
const AnonymousUtils = {
4547
/**
4648
* Gets whether the user has their account linked to anonymous user.
4749
*
48-
* @method isLinked
50+
* @function isLinked
4951
* @name Parse.AnonymousUtils.isLinked
5052
* @param {Parse.User} user User to check for.
5153
* The user must be logged in on this device.
52-
* @return {Boolean} <code>true</code> if the user has their account
54+
* @returns {boolean} <code>true</code> if the user has their account
5355
* linked to an anonymous user.
5456
* @static
5557
*/
@@ -61,28 +63,28 @@ const AnonymousUtils = {
6163
/**
6264
* Logs in a user Anonymously.
6365
*
64-
* @method logIn
66+
* @function logIn
6567
* @name Parse.AnonymousUtils.logIn
66-
* @param {Object} options MasterKey / SessionToken.
67-
* @returns {Promise}
68+
* @param {object} options MasterKey / SessionToken.
69+
* @returns {Promise} Logged in user
6870
* @static
6971
*/
70-
logIn(options?: RequestOptions) {
72+
logIn(options?: RequestOptions): Promise<ParseUser> {
7173
const provider = this._getAuthProvider();
7274
return ParseUser.logInWith(provider.getAuthType(), provider.getAuthData(), options);
7375
},
7476

7577
/**
7678
* Links Anonymous User to an existing PFUser.
7779
*
78-
* @method link
80+
* @function link
7981
* @name Parse.AnonymousUtils.link
8082
* @param {Parse.User} user User to link. This must be the current user.
81-
* @param {Object} options MasterKey / SessionToken.
82-
* @returns {Promise}
83+
* @param {object} options MasterKey / SessionToken.
84+
* @returns {Promise} Linked with User
8385
* @static
8486
*/
85-
link(user: ParseUser, options?: RequestOptions) {
87+
link(user: ParseUser, options?: RequestOptions): Promise<ParseUser> {
8688
const provider = this._getAuthProvider();
8789
return user.linkWith(provider.getAuthType(), provider.getAuthData(), options);
8890
},

0 commit comments

Comments
 (0)