@playcanvas/attribute-parser 1.5.0 → 1.5.1

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.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
7
7
  },
8
- "version": "1.5.0",
8
+ "version": "1.5.1",
9
9
  "dependencies": {
10
10
  "@playcanvas/eslint-config": "^1.7.4 || ^2.0.0",
11
11
  "@typescript/vfs": "^1.6.0",
@@ -218,9 +218,19 @@ export function getJSDocTags(node, typeChecker) {
218
218
  heritageChain.forEach((classNode) => {
219
219
  // for each class iterate over it's class members
220
220
  classNode.members.forEach((member) => {
221
- if (ts.isPropertyDeclaration(member) || ts.isSetAccessor(member) || ts.isPropertySignature(member)) {
221
+ const isSetter = ts.isSetAccessor(member);
222
+ if (ts.isPropertyDeclaration(member) || isSetter || ts.isPropertySignature(member)) {
222
223
  const memberName = member.name && ts.isIdentifier(member.name) ? member.name.text : 'unnamed';
223
- const hasJsDoc = member.jsDoc?.length > 0;
224
+
225
+ let hasJsDoc = member.jsDoc?.length > 0;
226
+
227
+ // If we are a setter with no jsdoc block, check any associated getter
228
+ if (isSetter && !hasJsDoc) {
229
+ const symbol = typeChecker.getSymbolAtLocation(member.name);
230
+ member = symbol.declarations.find(accessor => accessor.jsDoc?.length > 0);
231
+ hasJsDoc = !!member;
232
+ }
233
+
224
234
  if (hasJsDoc) {
225
235
  tags.push({
226
236
  memberName,
@@ -12,6 +12,8 @@ class Example extends Script {
12
12
 
13
13
  _b = 10;
14
14
 
15
+ _d = 10;
16
+
15
17
  /**
16
18
  * @attribute
17
19
  * @type {number}
@@ -28,6 +30,20 @@ class Example extends Script {
28
30
  * @type {number}
29
31
  */
30
32
  c;
33
+
34
+ /**
35
+ * Reverse order gett/setter accessor
36
+ * @attribute
37
+ * @type {number}
38
+ */
39
+ get d() {
40
+ return this._d;
41
+ }
42
+
43
+ // eslint-disable-next-line grouped-accessor-pairs
44
+ set d(v) {
45
+ this._d = v;
46
+ }
31
47
  }
32
48
 
33
49
  export { Example };
@@ -43,4 +43,12 @@ describe('VALID: Misc attribute types', function () {
43
43
  expect(data[0].example.attributes.c).to.not.exist;
44
44
  });
45
45
 
46
+ it('d: should be a numeric attribute with a getter and setter defined in reverse order', function () {
47
+ expect(data[0].example.attributes.d).to.exist;
48
+ expect(data[0].example.attributes.d.name).to.equal('d');
49
+ expect(data[0].example.attributes.d.type).to.equal('number');
50
+ expect(data[0].example.attributes.d.array).to.equal(false);
51
+ expect(data[0].example.attributes.d.default).to.equal(0);
52
+ });
53
+
46
54
  });
package/rollup.config.js DELETED
@@ -1,33 +0,0 @@
1
- import commonjs from '@rollup/plugin-commonjs';
2
- import resolve from '@rollup/plugin-node-resolve';
3
- import swc from '@rollup/plugin-swc';
4
-
5
- export default {
6
- input: 'src/index.js',
7
- treeshake: { moduleSideEffects: false },
8
- // Mark 'typescript' as external, so it won’t get bundled
9
- // external: ['typescript'],
10
- output: {
11
- dir: 'dist',
12
- format: 'esm'
13
- },
14
- plugins: [
15
- commonjs({
16
- include: /node_modules/,
17
- ignoreGlobal: true,
18
- sourceMap: false
19
- }),
20
- resolve({
21
- browser: true, // This instructs the plugin to resolve for the browser
22
- preferBuiltins: false // Prefer the local versions of built-ins instead of Node.js versions
23
- }),
24
- swc({ swc: {
25
- minify: true,
26
- jsc: {
27
- minify: {
28
- compress: true
29
- }
30
- }
31
- } })
32
- ]
33
- };