@playcanvas/attribute-parser 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc +19 -0
  3. package/.github/workflows/ci.yml +3 -0
  4. package/package.json +6 -2
  5. package/src/index.js +13 -13
  6. package/src/parsers/attribute-parser.js +8 -9
  7. package/src/parsers/script-parser.js +20 -19
  8. package/src/utils/attribute-utils.js +6 -8
  9. package/src/utils/tag-utils.js +3 -3
  10. package/src/utils/ts-utils.js +2 -3
  11. package/test/fixtures/asset.invalid.js +1 -0
  12. package/test/fixtures/asset.valid.js +1 -0
  13. package/test/fixtures/curve.invalid.js +1 -0
  14. package/test/fixtures/enum.valid.js +5 -2
  15. package/test/fixtures/export.import.js +1 -1
  16. package/test/fixtures/export.valid.js +5 -5
  17. package/test/fixtures/inherit.valid.js +2 -3
  18. package/test/fixtures/json.invalid.js +1 -0
  19. package/test/fixtures/json.valid.js +3 -0
  20. package/test/fixtures/misc.invalid.js +2 -3
  21. package/test/fixtures/misc.valid.js +1 -1
  22. package/test/fixtures/program.invalid.js +2 -1
  23. package/test/fixtures/program.valid.js +18 -0
  24. package/test/fixtures/text.valid.js +1 -0
  25. package/test/fixtures/vector.invalid.js +1 -0
  26. package/test/fixtures/vector.valid.js +1 -0
  27. package/test/tests/invalid/asset.test.js +1 -2
  28. package/test/tests/invalid/curve.test.js +1 -2
  29. package/test/tests/invalid/json.test.js +1 -2
  30. package/test/tests/invalid/misc.test.js +1 -2
  31. package/test/tests/invalid/numeric.test.js +1 -2
  32. package/test/tests/invalid/program.test.js +2 -3
  33. package/test/tests/invalid/vector.test.js +1 -2
  34. package/test/tests/valid/asset.test.js +1 -2
  35. package/test/tests/valid/checkbox.test.js +1 -2
  36. package/test/tests/valid/color.test.js +1 -2
  37. package/test/tests/valid/curve.test.js +1 -2
  38. package/test/tests/valid/entity.test.js +1 -2
  39. package/test/tests/valid/enum.test.js +1 -2
  40. package/test/tests/valid/export.test.js +1 -2
  41. package/test/tests/valid/inherit.test.js +1 -2
  42. package/test/tests/valid/intellisense.test.js +1 -2
  43. package/test/tests/valid/json.test.js +1 -2
  44. package/test/tests/valid/misc.test.js +1 -2
  45. package/test/tests/valid/numeric.test.js +1 -2
  46. package/test/tests/valid/program.test.js +17 -0
  47. package/test/tests/valid/text.test.js +1 -2
  48. package/test/tests/valid/vector.test.js +1 -2
  49. package/test/utils.js +2 -1
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ /**/program.invalid.js
package/.eslintrc ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": [
3
+ "@playcanvas/eslint-config"
4
+ ],
5
+ "rules": {
6
+ "no-unused-expressions": "off",
7
+ "jsdoc/check-tag-names": "off",
8
+ "import/no-unresolved": "off"
9
+ },
10
+ "overrides": [
11
+ {
12
+ "files": ["./**/*.test.js"],
13
+ "rules": {
14
+ "prefer-arrow-callback": "off",
15
+ }
16
+ }
17
+ ]
18
+ }
19
+
@@ -24,5 +24,8 @@ jobs:
24
24
  - name: Install dependencies
25
25
  run: npm clean-install --progress=false --no-fund
26
26
 
27
+ - name: Run ESLint
28
+ run: npm run lint
29
+
27
30
  - name: Run unit tests
28
31
  run: npm test
package/package.json CHANGED
@@ -5,18 +5,22 @@
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
7
7
  },
8
- "version": "1.0.3",
8
+ "version": "1.0.5",
9
9
  "dependencies": {
10
10
  "@microsoft/tsdoc": "^0.15.0",
11
+ "@playcanvas/eslint-config": "^1.7.4",
11
12
  "@typescript/vfs": "^1.6.0",
13
+ "eslint": "^8.56.0",
12
14
  "typescript": "^5.5.3"
13
15
  },
14
16
  "devDependencies": {
15
17
  "chai": "^5.1.1",
18
+ "globals": "^15.9.0",
16
19
  "mocha": "^10.6.0"
17
20
  },
18
21
  "scripts": {
19
- "test": "mocha test/**/*.test.js --timeout 10000"
22
+ "test": "mocha test/**/*.test.js --timeout 10000",
23
+ "lint": "eslint ."
20
24
  },
21
25
  "publishConfig": {
22
26
  "access": "public"
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import * as ts from 'typescript';
2
1
  import { createSystem, createDefaultMapFromNodeModules, createVirtualTypeScriptEnvironment } from '@typescript/vfs';
2
+ import * as ts from 'typescript';
3
3
 
4
4
  import { ScriptParser } from './parsers/script-parser.js';
5
5
  import { createDefaultMapFromCDN, flatMapAnyNodes, getExportedNodes, getType, inheritsFrom, isAliasedClassDeclaration } from './utils/ts-utils.js';
@@ -7,15 +7,15 @@ import { createDefaultMapFromCDN, flatMapAnyNodes, getExportedNodes, getType, in
7
7
  const toLowerCamelCase = str => str[0].toLowerCase() + str.substring(1);
8
8
 
9
9
  const COMPILER_OPTIONS = {
10
- strictPropertyInitialization: false, // Allow uninitialized properties
10
+ strict: false,
11
+ skipLibCheck: true, // Skip type checking of declaration files
11
12
  target: ts.ScriptTarget.ES2022, // If this version changes, the types must be updated in the /rollup.config.mjs
12
13
  module: ts.ModuleKind.CommonJS,
13
14
  checkJs: true, // Enable JSDoc parsing
14
15
  allowJs: true,
15
- noImplicitAny: false, // Allow implicit any
16
16
  baseUrl: './',
17
17
  paths: {
18
- "playcanvas": ["/playcanvas.js"]
18
+ 'playcanvas': ['/playcanvas.js']
19
19
  }
20
20
  };
21
21
 
@@ -34,7 +34,7 @@ export class JSDocParser {
34
34
 
35
35
  /**
36
36
  * Initializes the JSDocParser with the standard library files
37
- *
37
+ *
38
38
  * @param {string} libPath - The path to standard library files
39
39
  * @returns {Promise<JSDocParser>} - The initialized JSDocParser
40
40
  */
@@ -96,7 +96,7 @@ export class JSDocParser {
96
96
 
97
97
  /**
98
98
  * Returns all the valid ESM Scripts within a file
99
- * @param fileName - The file name in the program to check
99
+ * @param {string} fileName - The file name in the program to check
100
100
  * @returns {import('typescript').Node[]} - An array of any exported ESM Script nodes within the file
101
101
  */
102
102
  getAllEsmScripts(fileName) {
@@ -107,16 +107,16 @@ export class JSDocParser {
107
107
  const pcTypes = this.program.getSourceFile('/playcanvas.d.ts');
108
108
 
109
109
  if (!pcTypes) {
110
- throw new Error(`PlayCanvas Types must be supplied`);
110
+ throw new Error('PlayCanvas Types must be supplied');
111
111
  }
112
-
112
+
113
113
  // Parse the source file and pc types
114
114
  const sourceFile = this.program.getSourceFile(fileName);
115
-
115
+
116
116
  if (!sourceFile) {
117
117
  throw new Error(`Source file ${fileName} not found`);
118
118
  }
119
-
119
+
120
120
  // Extract all exported nodes
121
121
  const nodes = getExportedNodes(this.program, sourceFile);
122
122
 
@@ -137,7 +137,7 @@ export class JSDocParser {
137
137
  const results = {};
138
138
  const errors = [...this._errors];
139
139
 
140
- if(errors.length > 0 ){
140
+ if (errors.length > 0) {
141
141
  return [results, errors];
142
142
  }
143
143
 
@@ -163,7 +163,7 @@ export class JSDocParser {
163
163
  const results = {};
164
164
  const errors = [...this._errors];
165
165
 
166
- if(errors.length > 0 ){
166
+ if (errors.length > 0) {
167
167
  return [results, errors];
168
168
  }
169
169
 
@@ -201,7 +201,7 @@ export class JSDocParser {
201
201
  }
202
202
 
203
203
  // Extract JSDoc tags
204
- const tags = member.jsDoc.map(jsdoc => jsdoc.tags?.map(tag => tag.tagName.getText()) ?? []).flat();
204
+ const tags = member.jsDoc ? member.jsDoc.map(jsdoc => jsdoc.tags?.map(tag => tag.tagName.getText()) ?? []).flat() : [];
205
205
 
206
206
  const name = member.name.getText();
207
207
  const type = getType(member, typeChecker);
@@ -1,10 +1,10 @@
1
+ import { TSDocConfiguration, TSDocTagDefinition, TSDocTagSyntaxKind, TextRange, TSDocParser } from '@microsoft/tsdoc';
1
2
  import * as ts from 'typescript';
2
- import { TSDocConfiguration, TSDocTagDefinition, TSDocTagSyntaxKind, TextRange, TSDocParser } from "@microsoft/tsdoc";
3
- import { extractTextFromDocNode, getLeadingBlockCommentRanges, getType } from '../utils/ts-utils.js';
4
3
 
5
- import { ParsingError } from "./parsing-error.js";
6
- import { hasTag } from "../utils/attribute-utils.js";
7
- import { parseTag, validateTag } from "../utils/tag-utils.js";
4
+ import { ParsingError } from './parsing-error.js';
5
+ import { hasTag } from '../utils/attribute-utils.js';
6
+ import { parseTag, validateTag } from '../utils/tag-utils.js';
7
+ import { extractTextFromDocNode, getLeadingBlockCommentRanges, getType } from '../utils/ts-utils.js';
8
8
 
9
9
  /**
10
10
  * A class to parse JSDoc comments and extract attribute metadata.
@@ -197,7 +197,7 @@ export class AttributeParser {
197
197
  } else {
198
198
  // Check for JSDoc annotations
199
199
  const jsDocs = ts.getJSDocTags(node);
200
- const typeTag = jsDocs.find(doc => doc.tagName.text === "type");
200
+ const typeTag = jsDocs.find(doc => doc.tagName.text === 'type');
201
201
  if (typeTag && ts.isJSDocTypeTag(typeTag)) {
202
202
  typeNode = typeTag.typeExpression;
203
203
  }
@@ -227,7 +227,7 @@ export class AttributeParser {
227
227
 
228
228
  // Additionally check for JSDoc enum tag
229
229
  const jsDocs = ts.getJSDocTags(declaration);
230
- const enumTag = jsDocs.find(doc => doc.tagName.text === "enum");
230
+ const enumTag = jsDocs.find(doc => doc.tagName.text === 'enum');
231
231
  if (enumTag && ts.isJSDocEnumTag(enumTag)) {
232
232
  // This assumes enum members are correctly annotated in JSDoc comments
233
233
  // Example: @enum {type} EnumName { Member1, Member2 }
@@ -245,10 +245,9 @@ export class AttributeParser {
245
245
  * Extract the public members and their values from a TypeScript node.
246
246
  *
247
247
  * @param {ts.Node} node - The node to parse
248
- * @param {ParsingError[]} errors - An array to store any parsing errors
249
248
  * @returns {any[]} - The extracted members
250
249
  */
251
- getMembers(node, errors = []) {
250
+ getMembers(node) {
252
251
 
253
252
  const members = [];
254
253
 
@@ -1,11 +1,11 @@
1
- import * as ts from 'typescript';
2
1
  import { TextRange } from '@microsoft/tsdoc';
2
+ import * as ts from 'typescript';
3
3
 
4
4
  import { AttributeParser } from './attribute-parser.js';
5
5
  import { ParsingError } from './parsing-error.js';
6
- import { zipArrays } from '../utils/generic-utils.js';
7
6
  import { hasTag } from '../utils/attribute-utils.js';
8
- import { flatMapAnyNodes, getJSDocCommentRanges, parseArrayLiteral, parseBooleanNode, parseFloatNode, parseStringNode } from "../utils/ts-utils.js";
7
+ import { zipArrays } from '../utils/generic-utils.js';
8
+ import { flatMapAnyNodes, getJSDocCommentRanges, parseArrayLiteral, parseBooleanNode, parseFloatNode, parseStringNode } from '../utils/ts-utils.js';
9
9
 
10
10
  /**
11
11
  * @typedef {object} Attribute
@@ -72,27 +72,27 @@ const createArrayArgumentParser = (name, defaultArr = []) => (
72
72
  * eg `new Vec3(1, 2, 3)`
73
73
  */
74
74
  const SUPPORTED_INITIALIZABLE_TYPE_NAMES = new Map([
75
- ["Curve", createArrayArgumentParser("Curve")],
76
- ["Vec2", createNumberArgumentParser("Vec2", [0, 0])],
77
- ["Vec3", createNumberArgumentParser("Vec3", [0, 0, 0])],
78
- ["Vec4", createNumberArgumentParser("Vec4", [0, 0, 0, 0])],
79
- ["Color", createNumberArgumentParser("Color", [1, 1, 1, 1])],
80
- ["number", parseFloatNode],
81
- ["string", parseStringNode],
82
- ["boolean", parseBooleanNode]
75
+ ['Curve', createArrayArgumentParser('Curve')],
76
+ ['Vec2', createNumberArgumentParser('Vec2', [0, 0])],
77
+ ['Vec3', createNumberArgumentParser('Vec3', [0, 0, 0])],
78
+ ['Vec4', createNumberArgumentParser('Vec4', [0, 0, 0, 0])],
79
+ ['Color', createNumberArgumentParser('Color', [1, 1, 1, 1])],
80
+ ['number', parseFloatNode],
81
+ ['string', parseStringNode],
82
+ ['boolean', parseBooleanNode]
83
83
  ]);
84
84
 
85
85
  /**
86
86
  * The full set of supported PlayCanvas types.
87
87
  */
88
88
  const SUPPORTED_PLAYCANVAS_TYPES = new Set([
89
- "Curve",
90
- "Asset",
91
- "Entity",
92
- "Vec2",
93
- "Vec3",
94
- "Vec4",
95
- "Color"
89
+ 'Curve',
90
+ 'Asset',
91
+ 'Entity',
92
+ 'Vec2',
93
+ 'Vec3',
94
+ 'Vec4',
95
+ 'Color'
96
96
  ]);
97
97
 
98
98
  /**
@@ -260,7 +260,8 @@ export class ScriptParser {
260
260
  validateProgram(errors = []) {
261
261
 
262
262
  // Report any compiler errors
263
- const compilerDiagnostics = this.program.getSemanticDiagnostics();
263
+ const compilerDiagnostics = this.program.getSyntacticDiagnostics();
264
+
264
265
  if (compilerDiagnostics.length > 0) {
265
266
  for (const diagnostic of compilerDiagnostics) {
266
267
  const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
@@ -13,26 +13,24 @@ export const getTagFromJsdoc = (tag, doc) => {
13
13
  return doc?.tags?.find(doc => doc.tagName.text === tag);
14
14
  };
15
15
 
16
-
17
16
  /**
18
17
  * Checks if a node has a specific JSDoc tag.
19
18
  * @param {string} tag - The tag to search for
20
19
  * @param {import("typescript").Node} node - The node to analyze
21
- * @returns {boolean} - True if the tag is found
20
+ * @returns {import('typescript').Node} - True if the tag is found
22
21
  */
23
- export const hasTag = (tag, node) => {
24
- return !!getTag(tag, node);
22
+ export const getTag = (tag, node) => {
23
+ return node?.jsDoc?.find(doc => getTagFromJsdoc(tag, doc));
25
24
  };
26
25
 
27
-
28
26
  /**
29
27
  * Checks if a node has a specific JSDoc tag.
30
28
  * @param {string} tag - The tag to search for
31
29
  * @param {import("typescript").Node} node - The node to analyze
32
- * @returns {import('typescript').Node} - True if the tag is found
30
+ * @returns {boolean} - True if the tag is found
33
31
  */
34
- export const getTag = (tag, node) => {
35
- return node?.jsDoc?.find(doc => getTagFromJsdoc(tag, doc));
32
+ export const hasTag = (tag, node) => {
33
+ return !!getTag(tag, node);
36
34
  };
37
35
 
38
36
 
@@ -22,12 +22,12 @@ export function parseTag(input = '') {
22
22
  try {
23
23
  const arr = parseStringToNumericalArray(input);
24
24
  if (Array.isArray(arr)) return arr;
25
- } catch (e) {}
25
+ } catch { /* eslint-disable-next-line no-empty */ }
26
26
 
27
27
  try {
28
28
  const arr = JSON.parse(input);
29
29
  if (Array.isArray(arr)) return arr;
30
- } catch (e) {}
30
+ } catch { /* eslint-disable-next-line no-empty */ }
31
31
 
32
32
  // If none of the above, return the string
33
33
  return input;
@@ -45,7 +45,7 @@ export function parseTag(input = '') {
45
45
  export function validateTag(value, typeAnnotation, env) {
46
46
 
47
47
  const sourceText = `let a: ${typeAnnotation} = ${value};`;
48
- env.createFile("/___virtual__.ts", sourceText);
48
+ env.createFile('/___virtual__.ts', sourceText);
49
49
 
50
50
  // Get the program and check for semantic errors
51
51
  const program = env.languageService.getProgram();
@@ -1,6 +1,7 @@
1
1
  import { DocNodeKind } from '@microsoft/tsdoc';
2
2
  import { knownLibFilesForCompilerOptions } from '@typescript/vfs';
3
3
  import * as ts from 'typescript';
4
+
4
5
  import { ParsingError } from '../parsers/parsing-error.js';
5
6
 
6
7
  export function createDefaultMapFromCDN(options, prefix, ts) {
@@ -19,9 +20,7 @@ export function createDefaultMapFromCDN(options, prefix, ts) {
19
20
 
20
21
  const contents = await Promise.all(contentPromises);
21
22
 
22
- contents.forEach(function (text, index) {
23
- return fsMap.set('/' + files[index], text);
24
- });
23
+ contents.forEach((text, index) => fsMap.set(`/${files[index]}`, text));
25
24
 
26
25
  return fsMap;
27
26
  }
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line
1
2
  import { Script, Asset } from 'playcanvas';
2
3
 
3
4
  class Example extends Script {
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line
1
2
  import { Script, Asset } from 'playcanvas';
2
3
 
3
4
  class Example extends Script {
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line
1
2
  import { Script, Curve } from 'playcanvas';
2
3
 
3
4
  class Example extends Script {
@@ -12,15 +12,17 @@ const NumberEnum = {
12
12
  /**
13
13
  * @enum {string}
14
14
  */
15
+ // eslint-disable-next-line
15
16
  const StringEnum = {
16
17
  A: 'a',
17
18
  B: 'b',
18
19
  C: 'c'
19
- }
20
+ };
20
21
 
21
22
  /**
22
23
  * @enum {Vec3}
23
24
  */
25
+ // eslint-disable-next-line
24
26
  const Vec3Enum = {
25
27
  A: new Vec3(1, 2, 3),
26
28
  B: new Vec3(4, 5, 6),
@@ -30,11 +32,12 @@ const Vec3Enum = {
30
32
  /**
31
33
  * @enum {NumberEnum}
32
34
  */
35
+ // eslint-disable-next-line
33
36
  const NumberNumberEnum = {
34
37
  A: NumberEnum.A,
35
38
  B: NumberEnum.B,
36
39
  C: NumberEnum.C
37
- }
40
+ };
38
41
 
39
42
  class Example extends Script {
40
43
  /**
@@ -1,3 +1,3 @@
1
1
  import { Script } from 'playcanvas';
2
2
 
3
- export class ExampleImport extends Script {}
3
+ export class ExampleImport extends Script {}
@@ -1,18 +1,18 @@
1
-
2
1
  import { Script } from 'playcanvas';
3
2
 
4
3
  import { ExampleImport } from './export.import.js';
5
4
 
6
- class ExampleImportExtend extends ExampleImport {};
5
+ class ExampleImportExtend extends ExampleImport {}
7
6
 
8
7
  export { ExampleImport as ExampleImportExportAs } from './export.import.js';
9
8
 
10
- class Example extends Script {};
9
+ class Example extends Script {}
11
10
 
12
- export default class ExampleDefault extends Script {};
11
+ export default class ExampleDefault extends Script {}
13
12
 
14
13
  export class ExampleExport extends Script {}
15
14
 
15
+ // eslint-disable-next-line
16
16
  class ExampleNotExported extends Script {}
17
17
 
18
18
  export {
@@ -20,4 +20,4 @@ export {
20
20
  Example as ExampleExportAs,
21
21
  ExampleImport,
22
22
  ExampleImportExtend
23
- }
23
+ };
@@ -1,4 +1,3 @@
1
-
2
1
  import { Script } from 'playcanvas';
3
2
 
4
3
  class Example extends Script {
@@ -7,7 +6,7 @@ class Example extends Script {
7
6
  * @type {boolean}
8
7
  */
9
8
  a;
10
- };
9
+ }
11
10
 
12
11
  class ExampleExtended extends Example {
13
12
  /**
@@ -15,7 +14,7 @@ class ExampleExtended extends Example {
15
14
  * @type {number}
16
15
  */
17
16
  b;
18
- };
17
+ }
19
18
 
20
19
  class ExampleExtendedExtended extends ExampleExtended {
21
20
  /**
@@ -1,5 +1,6 @@
1
1
  import { Script } from 'playcanvas';
2
2
 
3
+ // eslint-disable-next-line
3
4
  class NoInterfaceFolder {
4
5
  /**
5
6
  * @attribute
@@ -3,6 +3,7 @@ import { Script, Vec3 } from 'playcanvas';
3
3
  /**
4
4
  * @interface
5
5
  */
6
+ // eslint-disable-next-line
6
7
  class Folder {
7
8
  /**
8
9
  * @attribute
@@ -26,7 +27,9 @@ class Folder {
26
27
 
27
28
  /**
28
29
  * @interface
30
+ *
29
31
  */
32
+ // eslint-disable-next-line
30
33
  class NestedFolder {
31
34
  /**
32
35
  * @attribute
@@ -1,7 +1,6 @@
1
- import { Script } from 'playcanvas';
2
- import { GraphNode } from './playcanvas';
1
+ import { Script, GraphNode } from 'playcanvas';
3
2
 
4
- class Vec3 {};
3
+ class Vec3 {}
5
4
 
6
5
  class Example extends Script {
7
6
  /**
@@ -3,7 +3,7 @@ import { Script } from 'playcanvas';
3
3
  class Example extends Script {
4
4
  /**
5
5
  * This is a description of the attribute.
6
- *
6
+ *
7
7
  * @attribute
8
8
  * @type {number}
9
9
  * @title A number
@@ -1,6 +1,7 @@
1
+ /* eslint-disable */
1
2
  import { Script } from 'playcanvas';
2
3
 
3
- class Example extends Script {
4
+ Class Intentionally extends Invalid {
4
5
  /**
5
6
  * @attribute
6
7
  * @type {boolean}
@@ -0,0 +1,18 @@
1
+ import * as TWEEN from 'https://cdnjs.cloudflare.com/ajax/libs/tween.js/23.1.2/tween.esm.js';
2
+ import confetti from 'https://esm.sh/canvas-confetti@1.6.0';
3
+ import { Script } from 'playcanvas';
4
+
5
+ class Example extends Script {
6
+ /**
7
+ * @attribute
8
+ * @type {boolean}
9
+ */
10
+ a = false;
11
+
12
+ initialize() {
13
+ confetti();
14
+ new TWEEN.Tween({ x: 0 }).to({ x: 100 }, 1000).start();
15
+ }
16
+ }
17
+
18
+ export { Example };
@@ -1,3 +1,4 @@
1
+ // eslint-disable
1
2
  import { Script } from 'playcanvas';
2
3
 
3
4
  class Example extends Script {
@@ -1,5 +1,6 @@
1
1
  import { Script, Vec3 } from 'playcanvas';
2
2
 
3
+ // eslint-disable-next-line
3
4
  class Vec3Extended extends Vec3 {};
4
5
 
5
6
  class Example extends Script {
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line
1
2
  import { Script, Vec2, Vec3, Vec4 } from 'playcanvas';
2
3
 
3
4
  class Example extends Script {
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -13,6 +12,6 @@ describe('INVALID: Program ', function () {
13
12
  it('only errors should exist (1)', function () {
14
13
  expect(data).to.exist;
15
14
  expect(data[0]).to.be.empty;
16
- expect(data[1].length).to.equal(1);
15
+ expect(data[1].length).to.equal(4);
17
16
  });
18
17
  });
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { getAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -0,0 +1,17 @@
1
+ import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
3
+
4
+ import { parseAttributes } from '../../utils.js';
5
+
6
+ describe('VALID: Program ', function () {
7
+ let data;
8
+ before(async function () {
9
+ data = await parseAttributes('./program.valid.js');
10
+ });
11
+
12
+ it('only results should exist', function () {
13
+ expect(data).to.exist;
14
+ expect(data[0]).to.not.be.empty;
15
+ expect(data[1]).to.be.empty;
16
+ });
17
+ });
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
@@ -1,6 +1,5 @@
1
- /* eslint-disable no-unused-expressions */
2
- import { describe, it, before } from 'mocha';
3
1
  import { expect } from 'chai';
2
+ import { describe, it, before } from 'mocha';
4
3
 
5
4
  import { parseAttributes } from '../../utils.js';
6
5
 
package/test/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs/promises';
2
- import { fileURLToPath } from 'url';
3
2
  import path, { dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
4
5
  import { JSDocParser } from '../src/index.js';
5
6
 
6
7
  const __filename = fileURLToPath(import.meta.url);