Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/CSS.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion api/Document.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion api/IDBKeyRange.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 2 additions & 0 deletions api/LanguageModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
},
"availability_static": {
"__compat": {
"description": "`availability()` static method",
"spec_url": "https://webmachinelearning.github.io/prompt-api/#dom-languagemodel-availability",
"support": {
"chrome": {
Expand Down Expand Up @@ -240,6 +241,7 @@
},
"create_static": {
"__compat": {
"description": "`create()` static method",
"spec_url": "https://webmachinelearning.github.io/prompt-api/#dom-languagemodel-create",
"support": {
"chrome": {
Expand Down
13 changes: 13 additions & 0 deletions lint/linter/test-descriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
80 changes: 80 additions & 0 deletions lint/linter/test-descriptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} */
Expand Down
Loading