diff --git a/api/CSS.json b/api/CSS.json index c418af7d8c426b..47b360d1bb86d4 100644 --- a/api/CSS.json +++ b/api/CSS.json @@ -223,7 +223,7 @@ }, "cqb_static": { "__compat": { - "description": "`cbq()` static method", + "description": "`cqb()` static method", "mdn_url": "https://developer.mozilla.org/docs/Web/API/CSS/factory_functions_static", "spec_url": "https://drafts.css-houdini.org/css-typed-om/#dom-css-cqb", "tags": [ @@ -482,7 +482,7 @@ }, "dpcm_static": { "__compat": { - "description": "`dpqm()` static method", + "description": "`dpcm()` static method", "mdn_url": "https://developer.mozilla.org/docs/Web/API/CSS/factory_functions_static", "spec_url": "https://drafts.css-houdini.org/css-typed-om/#dom-css-dpcm", "tags": [ diff --git a/api/Document.json b/api/Document.json index 0486815d14d7df..aa1c281da048ac 100644 --- a/api/Document.json +++ b/api/Document.json @@ -6275,7 +6275,7 @@ }, "parseHTML_static": { "__compat": { - "description": "`parseHTML` static method", + "description": "`parseHTML()` static method", "mdn_url": "https://developer.mozilla.org/docs/Web/API/Document/parseHTML_static", "spec_url": "https://wicg.github.io/sanitizer-api/#dom-document-parsehtml", "tags": [ diff --git a/api/IDBKeyRange.json b/api/IDBKeyRange.json index cded8e679928f3..e095a107764551 100644 --- a/api/IDBKeyRange.json +++ b/api/IDBKeyRange.json @@ -310,7 +310,7 @@ }, "only_static": { "__compat": { - "description": "`lowerBound()` static method", + "description": "`only()` static method", "mdn_url": "https://developer.mozilla.org/docs/Web/API/IDBKeyRange/only_static", "spec_url": "https://w3c.github.io/IndexedDB/#ref-for-dom-idbkeyrange-only①", "tags": [ diff --git a/api/LanguageModel.json b/api/LanguageModel.json index 6dbc89e37ad3b5..eb5ff226b8a611 100644 --- a/api/LanguageModel.json +++ b/api/LanguageModel.json @@ -69,6 +69,7 @@ }, "availability_static": { "__compat": { + "description": "`availability()` static method", "spec_url": "https://webmachinelearning.github.io/prompt-api/#dom-languagemodel-availability", "support": { "chrome": { @@ -240,6 +241,7 @@ }, "create_static": { "__compat": { + "description": "`create()` static method", "spec_url": "https://webmachinelearning.github.io/prompt-api/#dom-languagemodel-create", "support": { "chrome": { diff --git a/lint/linter/test-descriptions.js b/lint/linter/test-descriptions.js index 81178416cd02be..fbd2e8cc446a21 100644 --- a/lint/linter/test-descriptions.js +++ b/lint/linter/test-descriptions.js @@ -79,6 +79,19 @@ const processApiData = (data, path, errors) => { `\`${featureName.replace('_permission', '')}\` permission`, errors, ); + } else if (featureName.endsWith('_static')) { + const memberName = featureName.slice(0, -'_static'.length); + const methodForm = `\`${memberName}()\` static method`; + const propertyForm = `\`${memberName}\` static property`; + const actual = data.description || ''; + if (!actual.startsWith(methodForm) && !actual.startsWith(propertyForm)) { + errors.push({ + ruleName: 'static', + path, + actual, + expected: methodForm, + }); + } } else if (featureName == 'secure_context_required') { checkDescription( 'secure context required', diff --git a/lint/linter/test-descriptions.test.js b/lint/linter/test-descriptions.test.js index ba4449e8adcd14..3568672acae31f 100644 --- a/lint/linter/test-descriptions.test.js +++ b/lint/linter/test-descriptions.test.js @@ -69,6 +69,86 @@ describe('test-descriptions', () => { ); }); + it('should check description for static method', () => { + const path = 'api.Interface.create_static'; + /** @type {CompatStatement} */ + const data = { + description: '', + support: {}, + }; + + const errors = processData(data, 'api', path); + assert.equal(errors.length, 1); + assert.equal( + /** @type {DescriptionError} */ (errors[0]).ruleName, + 'static', + ); + }); + + it('should accept static method description', () => { + const path = 'api.Interface.create_static'; + /** @type {CompatStatement} */ + const data = { + description: '`create()` static method', + support: {}, + }; + + const errors = processData(data, 'api', path); + assert.equal(errors.length, 0); + }); + + it('should accept static property description', () => { + const path = 'api.Interface.maxActions_static'; + /** @type {CompatStatement} */ + const data = { + description: '`maxActions` static property', + support: {}, + }; + + const errors = processData(data, 'api', path); + assert.equal(errors.length, 0); + }); + + it('should accept static method description with trailing context', () => { + const path = 'api.console.exception_static'; + /** @type {CompatStatement} */ + const data = { + description: '`exception()` static method (an alias for `error()`)', + support: {}, + }; + + const errors = processData(data, 'api', path); + assert.equal(errors.length, 0); + }); + + it('should reject static description with wrong name', () => { + const path = 'api.Interface.only_static'; + /** @type {CompatStatement} */ + const data = { + description: '`lowerBound()` static method', + support: {}, + }; + + const errors = processData(data, 'api', path); + assert.equal(errors.length, 1); + assert.equal( + /** @type {DescriptionError} */ (errors[0]).ruleName, + 'static', + ); + }); + + it('should ignore _static_property suffix', () => { + const path = 'api.Interface.disabledFeatures_static_property'; + /** @type {CompatStatement} */ + const data = { + description: 'Supports `disabledFeatures` static property', + support: {}, + }; + + const errors = processData(data, 'api', path); + assert.equal(errors.length, 0); + }); + it('should check description for secure context required', () => { const path = 'api.Interface.secure_context_required'; /** @type {CompatStatement} */