Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pre-commit:
- .vscode/*.json
- browsers/*.json
- schemas/*.json
run: npm run lint:fix {staged_files}
run: npm run lint:fix {staged_files} && git add lint/common/standard-track-exceptions.txt
stage_fixed: true

pre-push:
Expand Down
4 changes: 3 additions & 1 deletion lint/linter/test-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const { browsers } = bcd;
/** @import {Linter, LinterData} from '../types.js' */
/** @import {Logger} from '../utils.js' */
/** @import {BrowserName, CompatStatement} from '../../types/types.js' */
const standardTrackExceptions = new Set(await getStandardTrackExceptions());
export const standardTrackExceptions = new Set(
await getStandardTrackExceptions(),
);

// See: https://github.com/web-platform-dx/web-features/blob/main/docs/baseline.md#core-browser-set
const CORE_BROWSER_SET = new Set([
Expand Down
122 changes: 69 additions & 53 deletions lint/linter/test-status.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import assert from 'node:assert/strict';

import { Logger } from '../utils.js';

import test, { checkExperimental } from './test-status.js';
import test, {
checkExperimental,
standardTrackExceptions,
} from './test-status.js';

describe('checkExperimental', () => {
it('should return true when data is not experimental', () => {
Expand Down Expand Up @@ -211,68 +214,81 @@ describe('checkStatus', () => {
assert.ok(logger.messages[0].message.includes('should be set to'));
});

it('should not log error for features in exception list missing spec_url', () => {
/** @type {CompatStatement} */
const data = {
status: {
experimental: false,
standard_track: true,
deprecated: false,
},
support: {},
};
describe('standard-track-exceptions', () => {
beforeEach(() => {
standardTrackExceptions.add('api.Foo');
});

// This feature is in the exception list
test.check(logger, {
data,
path: { category: 'api', full: 'api.AudioProcessingEvent' },
afterEach(() => {
standardTrackExceptions.delete('api.Foo');
});

assert.equal(logger.messages.length, 0);
});
it('should not log error for features in exception list missing spec_url', () => {
/** @type {CompatStatement} */
const data = {
status: {
experimental: false,
standard_track: true,
deprecated: false,
},
support: {},
};

it('should log warning when exception no longer applies (has spec_url)', () => {
/** @type {CompatStatement} */
const data = {
status: {
experimental: false,
standard_track: true,
deprecated: false,
},
spec_url: 'https://example.com/spec',
support: {},
};
test.check(logger, {
data,
path: { category: 'api', full: 'api.Foo' },
});

// This feature is in the exception list but now has spec_url
test.check(logger, {
data,
path: { category: 'api', full: 'api.AudioProcessingEvent' },
// Feature is in the exception list.

assert.equal(logger.messages.length, 0);
});

assert.equal(logger.messages.length, 1);
assert.equal(logger.messages[0].level, 'warning');
assert.ok(logger.messages[0].message.includes('exception list'));
});
it('should log warning when exception no longer applies (has spec_url)', () => {
/** @type {CompatStatement} */
const data = {
status: {
experimental: false,
standard_track: true,
deprecated: false,
},
spec_url: 'https://example.com/spec',
support: {},
};

it('should log warning when exception no longer applies (standard_track false)', () => {
/** @type {CompatStatement} */
const data = {
status: {
experimental: false,
standard_track: false,
deprecated: false,
},
support: {},
};
test.check(logger, {
data,
path: { category: 'api', full: 'api.Foo' },
});

// This feature is in the exception list but standard_track is now false
test.check(logger, {
data,
path: { category: 'api', full: 'api.AudioProcessingEvent' },
// Feature is in the exception list but now has `spec_url`.

assert.equal(logger.messages.length, 1);
assert.equal(logger.messages[0].level, 'warning');
assert.ok(logger.messages[0].message.includes('exception list'));
});

assert.equal(logger.messages.length, 1);
assert.equal(logger.messages[0].level, 'warning');
assert.ok(logger.messages[0].message.includes('exception list'));
it('should log warning when exception no longer applies (standard_track false)', () => {
/** @type {CompatStatement} */
const data = {
status: {
experimental: false,
standard_track: false,
deprecated: false,
},
support: {},
};

test.check(logger, {
data,
path: { category: 'api', full: 'api.Foo' },
});

// Feature is in the exception list but `standard_track` is now false.

assert.equal(logger.messages.length, 1);
assert.equal(logger.messages[0].level, 'warning');
assert.ok(logger.messages[0].message.includes('exception list'));
});
});
});
Loading