@markuplint/rules 4.0.0-dev.20 → 4.0.0-dev.23

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 (35) hide show
  1. package/LICENSE +1 -1
  2. package/lib/attr-duplication/index.js +3 -0
  3. package/lib/attr-value-quotes/index.js +3 -1
  4. package/lib/case-sensitive-attr-name/index.js +3 -0
  5. package/lib/case-sensitive-tag-name/index.js +3 -0
  6. package/lib/character-reference/index.js +3 -0
  7. package/lib/class-naming/index.js +3 -0
  8. package/lib/deprecated-attr/index.js +3 -0
  9. package/lib/deprecated-element/index.js +3 -0
  10. package/lib/disallowed-element/index.js +3 -0
  11. package/lib/doctype/index.js +3 -0
  12. package/lib/end-tag/index.js +3 -0
  13. package/lib/id-duplication/index.js +3 -0
  14. package/lib/ineffective-attr/index.js +3 -0
  15. package/lib/invalid-attr/index.js +3 -0
  16. package/lib/label-has-control/index.js +3 -0
  17. package/lib/landmark-roles/index.js +3 -0
  18. package/lib/no-boolean-attr-value/index.js +3 -0
  19. package/lib/no-default-value/index.js +3 -0
  20. package/lib/no-empty-palpable-content/index.js +3 -0
  21. package/lib/no-hard-code-id/index.js +3 -0
  22. package/lib/no-refer-to-non-existent-id/index.js +3 -0
  23. package/lib/no-use-event-handler-attr/index.js +3 -0
  24. package/lib/permitted-contents/content-model.js +6 -3
  25. package/lib/permitted-contents/index.js +3 -0
  26. package/lib/placeholder-label-option/index.js +3 -0
  27. package/lib/require-accessible-name/index.js +3 -3
  28. package/lib/require-datetime/index.js +3 -0
  29. package/lib/required-attr/index.js +3 -0
  30. package/lib/required-element/index.js +3 -0
  31. package/lib/required-h1/index.js +3 -0
  32. package/lib/use-list/index.js +3 -0
  33. package/lib/wai-aria/checkings/required-owned-elements.js +1 -1
  34. package/lib/wai-aria/index.js +3 -0
  35. package/package.json +10 -10
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2023 Yusuke Hirao
3
+ Copyright (c) 2017-2024 Yusuke Hirao
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
3
6
  async verify({ document, report, t }) {
4
7
  const message = t('{0} is {1:c}', t('the {0}', 'attribute name'), 'duplicated');
5
8
  await document.walkOn('Element', node => {
@@ -4,6 +4,9 @@ const quoteList = {
4
4
  single: "'",
5
5
  };
6
6
  export default createRule({
7
+ meta: {
8
+ category: 'style',
9
+ },
7
10
  defaultSeverity: 'warning',
8
11
  defaultValue: 'double',
9
12
  async verify({ document, report, t }) {
@@ -26,7 +29,6 @@ export default createRule({
26
29
  const quote = quoteList[attr.rule.value];
27
30
  if (quote && attr.startQuote && attr.startQuote.raw !== quote) {
28
31
  attr.startQuote.fix(quote);
29
- // TODO: attr.endQuote = new MLToken(quote);
30
32
  attr.endQuote?.fix(quote);
31
33
  }
32
34
  });
@@ -1,5 +1,8 @@
1
1
  import { createRule, getAttrSpecs } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'style',
5
+ },
3
6
  defaultSeverity: 'warning',
4
7
  defaultValue: 'lower',
5
8
  async verify({ document, report, t }) {
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'style',
5
+ },
3
6
  defaultSeverity: 'warning',
4
7
  defaultValue: 'lower',
5
8
  async verify({ document, report, t }) {
@@ -2,6 +2,9 @@ import { createRule, getLocationFromChars } from '@markuplint/ml-core';
2
2
  const defaultChars = ['"', '&', '<', '>'];
3
3
  const ignoreParentElement = new Set(['script', 'style']);
4
4
  export default createRule({
5
+ meta: {
6
+ category: 'style',
7
+ },
5
8
  async verify({ document, report, t }) {
6
9
  const targetNodes = [];
7
10
  await document.walkOn('Text', node => {
@@ -2,6 +2,9 @@ import { createRule } from '@markuplint/ml-core';
2
2
  import { toNoEmptyStringArrayFromStringOrArray } from '@markuplint/shared';
3
3
  import { match } from '../helpers.js';
4
4
  export default createRule({
5
+ meta: {
6
+ category: 'naming-convention',
7
+ },
5
8
  defaultSeverity: 'warning',
6
9
  defaultValue: null,
7
10
  async verify({ document, report, t }) {
@@ -1,5 +1,8 @@
1
1
  import { createRule, getAttrSpecs } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
3
6
  async verify({ document, report, t }) {
4
7
  await document.walkOn('Attr', attr => {
5
8
  const attrSpecs = getAttrSpecs(attr.ownerElement, document.specs);
@@ -1,5 +1,8 @@
1
1
  import { createRule, getSpec } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
3
6
  async verify({ document, report, t }) {
4
7
  await document.walkOn('Element', el => {
5
8
  if (!(el.namespaceURI === 'http://www.w3.org/1999/xhtml' ||
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
3
6
  defaultValue: [],
4
7
  async verify({ document, report, t }) {
5
8
  for (const query of document.rule.value) {
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
3
6
  defaultValue: 'always',
4
7
  defaultOptions: {
5
8
  denyObsoleteType: true,
@@ -1,6 +1,9 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  import { isVoidElement } from '@markuplint/ml-spec';
3
3
  export default createRule({
4
+ meta: {
5
+ category: 'style',
6
+ },
4
7
  defaultSeverity: 'warning',
5
8
  async verify({ document, report, t }) {
6
9
  if (document.endTag === 'never') {
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
3
6
  async verify({ document, report, t }) {
4
7
  const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'value'), t('the "{0*}" {1}', 'id', 'attribute')), 'duplicated');
5
8
  const idStack = [];
@@ -1,6 +1,9 @@
1
1
  import { createRule, getAttrSpecs } from '@markuplint/ml-core';
2
2
  import { toNoEmptyStringArrayFromStringOrArray } from '@markuplint/shared';
3
3
  export default createRule({
4
+ meta: {
5
+ category: 'style',
6
+ },
4
7
  defaultSeverity: 'warning',
5
8
  async verify({ document, report, t }) {
6
9
  await document.walkOn('Attr', attr => {
@@ -4,6 +4,9 @@ import { log as ruleLog } from '../debug.js';
4
4
  import { isValidAttr, match } from '../helpers.js';
5
5
  const log = ruleLog.extend('invalid-attr');
6
6
  export default createRule({
7
+ meta: {
8
+ category: 'validation',
9
+ },
7
10
  defaultOptions: {},
8
11
  async verify({ document, report, t }) {
9
12
  await document.walkOn('Attr', attr => {
@@ -1,6 +1,9 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  const controlSelector = ["input:not([type='hidden' i])", 'select', 'textarea'].join(',');
3
3
  export default createRule({
4
+ meta: {
5
+ category: 'a11y',
6
+ },
4
7
  defaultSeverity: 'warning',
5
8
  async verify({ document, report, t }) {
6
9
  await document.walkOn('Element', el => {
@@ -10,6 +10,9 @@ const selectors = {
10
10
  };
11
11
  const topLevelRoles = ['banner', 'main', 'complementary', 'contentinfo'];
12
12
  export default createRule({
13
+ meta: {
14
+ category: 'a11y',
15
+ },
13
16
  defaultSeverity: 'warning',
14
17
  defaultOptions: {
15
18
  ignoreRoles: [],
@@ -1,5 +1,8 @@
1
1
  import { createRule, getAttrSpecs } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'style',
5
+ },
3
6
  defaultSeverity: 'warning',
4
7
  async verify({ document, report, t }) {
5
8
  await document.walkOn('Attr', attr => {
@@ -1,6 +1,9 @@
1
1
  import { createRule, getAttrSpecs } from '@markuplint/ml-core';
2
2
  import { toNormalizedValue } from '../helpers.js';
3
3
  export default createRule({
4
+ meta: {
5
+ category: 'style',
6
+ },
4
7
  defaultSeverity: 'warning',
5
8
  async verify({ document, report, t }) {
6
9
  await document.walkOn('Attr', attr => {
@@ -1,6 +1,9 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  import { isNothingContentModel, isPalpableElement } from '@markuplint/ml-spec';
3
3
  export default createRule({
4
+ meta: {
5
+ category: 'validation',
6
+ },
4
7
  defaultSeverity: 'warning',
5
8
  defaultOptions: {
6
9
  extendsExposableElements: true,
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'maintainability',
5
+ },
3
6
  defaultSeverity: 'warning',
4
7
  async verify({ document, report, t }) {
5
8
  if (!document.isFragment) {
@@ -3,6 +3,9 @@ import { ARIA_RECOMMENDED_VERSION } from '@markuplint/ml-spec';
3
3
  import { decodeEntities, decodeHref } from '@markuplint/shared';
4
4
  const HYPERLINK_SELECTOR = 'a[href], area[href]';
5
5
  export default createRule({
6
+ meta: {
7
+ category: 'a11y',
8
+ },
6
9
  defaultOptions: {
7
10
  ariaVersion: ARIA_RECOMMENDED_VERSION,
8
11
  fragmentRefersNameAttr: false,
@@ -1,6 +1,9 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  import { match } from '../helpers.js';
3
3
  export default createRule({
4
+ meta: {
5
+ category: 'maintainability',
6
+ },
4
7
  defaultSeverity: 'warning',
5
8
  defaultOptions: {},
6
9
  async verify({ document, report, t }) {
@@ -3,7 +3,7 @@ import { start } from './start.js';
3
3
  export function contentModel(
4
4
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
5
5
  el, rules, options) {
6
- const model = createModel(el, rules);
6
+ const { model, specs } = createModel(el, rules);
7
7
  if (model == null) {
8
8
  return [
9
9
  {
@@ -14,7 +14,7 @@ el, rules, options) {
14
14
  },
15
15
  ];
16
16
  }
17
- const result = start(model, el, el.ownerMLDocument.specs, options);
17
+ const result = start(model, el, specs, options);
18
18
  return result;
19
19
  }
20
20
  function createModel(
@@ -22,7 +22,10 @@ function createModel(
22
22
  el, rules) {
23
23
  const specs = cachedSpecs(el.ownerMLDocument.specs, rules);
24
24
  const model = getContentModel(el, specs.specs);
25
- return model;
25
+ return {
26
+ model,
27
+ specs,
28
+ };
26
29
  }
27
30
  const caches = new Map();
28
31
  function cachedSpecs(specs, rules) {
@@ -2,6 +2,9 @@ import { createRule } from '@markuplint/ml-core';
2
2
  import { contentModel } from './content-model.js';
3
3
  import { transparentMode } from './represent-transparent-nodes.js';
4
4
  export default createRule({
5
+ meta: {
6
+ category: 'validation',
7
+ },
5
8
  defaultValue: [],
6
9
  defaultOptions: {
7
10
  ignoreHasMutableChildren: true,
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
3
6
  verify({ document, report, t }) {
4
7
  for (const select of document.querySelectorAll('select')) {
5
8
  if (hasPlaceholderLabelOption(select)) {
@@ -2,14 +2,14 @@ import { createRule, getRoleSpec, getComputedRole } from '@markuplint/ml-core';
2
2
  import { ARIA_RECOMMENDED_VERSION, isExposed } from '@markuplint/ml-spec';
3
3
  import { accnameMayBeMutable } from '../helpers.js';
4
4
  export default createRule({
5
+ meta: {
6
+ category: 'a11y',
7
+ },
5
8
  defaultOptions: {
6
9
  ariaVersion: ARIA_RECOMMENDED_VERSION,
7
10
  },
8
11
  async verify({ document, report, t }) {
9
12
  await document.walkOn('Element', el => {
10
- if (el.pretenderContext?.type === 'pretender') {
11
- return;
12
- }
13
13
  if (accnameMayBeMutable(el, document)) {
14
14
  return;
15
15
  }
@@ -2,6 +2,9 @@ import { createRule } from '@markuplint/ml-core';
2
2
  import { check } from '@markuplint/types';
3
3
  import { getCandidateDatetimeString } from './utils.js';
4
4
  export default createRule({
5
+ meta: {
6
+ category: 'validation',
7
+ },
5
8
  defaultOptions: {
6
9
  langs: undefined,
7
10
  },
@@ -1,6 +1,9 @@
1
1
  import { createRule, getAttrSpecs } from '@markuplint/ml-core';
2
2
  import { attrMatches, match } from '../helpers.js';
3
3
  export default createRule({
4
+ meta: {
5
+ category: 'validation',
6
+ },
4
7
  defaultValue: [],
5
8
  async verify({ document, report, t }) {
6
9
  await document.walkOn('Element', el => {
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
3
6
  defaultValue: [],
4
7
  defaultOptions: {
5
8
  ignoreHasMutableContents: true,
@@ -1,5 +1,8 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  export default createRule({
3
+ meta: {
4
+ category: 'a11y',
5
+ },
3
6
  defaultOptions: {
4
7
  'expected-once': true,
5
8
  'in-document-fragment': false,
@@ -1,6 +1,9 @@
1
1
  import { createRule } from '@markuplint/ml-core';
2
2
  import { decodeEntities } from '@markuplint/shared';
3
3
  export default createRule({
4
+ meta: {
5
+ category: 'a11y',
6
+ },
4
7
  defaultValue: [
5
8
  /**
6
9
  * @see https://en.wikipedia.org/wiki/Bullet_(typography)#In_Unicode
@@ -75,7 +75,7 @@ export const checkingRequiredOwnedElements = ({ el, role }) => t => {
75
75
  if (mayBeBeforeCreated(el)) {
76
76
  return {
77
77
  scope: el,
78
- message: t('{0}. Or, {1}', t('require {0}', role.requiredOwnedElements.length === 1 && role.requiredOwnedElements[0]
78
+ message: t('{0}. Or, {1}', t('{0} requires {1}', t('the {0}', 'child element'), role.requiredOwnedElements.length === 1 && role.requiredOwnedElements[0]
79
79
  ? t('the "{0*}" {1}', role.requiredOwnedElements[0], 'role')
80
80
  : t('the {0}', 'roles') + `: ${t(role.requiredOwnedElements)}`), t('require {0}', 'aria-busy="true"')),
81
81
  };
@@ -16,6 +16,9 @@ import { checkingRequiredOwnedElements } from './checkings/required-owned-elemen
16
16
  import { checkingRequiredProp } from './checkings/required-prop.js';
17
17
  import { checkingValue } from './checkings/value.js';
18
18
  export default createRule({
19
+ meta: {
20
+ category: 'a11y',
21
+ },
19
22
  defaultOptions: {
20
23
  checkingValue: true,
21
24
  checkingDeprecatedProps: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/rules",
3
- "version": "4.0.0-dev.20+6b35da16",
3
+ "version": "4.0.0-dev.23+d6f2aa9bc",
4
4
  "description": "Built-in rules of markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -25,18 +25,18 @@
25
25
  "./lib/permitted-contents/debug.js": "./lib/permitted-contents/debug.browser.js"
26
26
  },
27
27
  "dependencies": {
28
- "@markuplint/html-spec": "4.0.0-dev.20+6b35da16",
29
- "@markuplint/ml-core": "4.0.0-dev.20+6b35da16",
30
- "@markuplint/ml-spec": "4.0.0-dev.20+6b35da16",
31
- "@markuplint/selector": "4.0.0-dev.20+6b35da16",
32
- "@markuplint/shared": "4.0.0-dev.20+6b35da16",
33
- "@markuplint/types": "4.0.0-dev.20+6b35da16",
28
+ "@markuplint/html-spec": "4.0.0-dev.23+d6f2aa9bc",
29
+ "@markuplint/ml-core": "4.0.0-dev.23+d6f2aa9bc",
30
+ "@markuplint/ml-spec": "4.0.0-dev.23+d6f2aa9bc",
31
+ "@markuplint/selector": "4.0.0-dev.23+d6f2aa9bc",
32
+ "@markuplint/shared": "4.0.0-dev.23+d6f2aa9bc",
33
+ "@markuplint/types": "4.0.0-dev.23+d6f2aa9bc",
34
34
  "@types/debug": "^4.1.12",
35
35
  "@ungap/structured-clone": "^1.2.0",
36
36
  "ansi-colors": "^4.1.3",
37
- "chrono-node": "^2.7.3",
37
+ "chrono-node": "^2.7.5",
38
38
  "debug": "^4.3.4",
39
- "type-fest": "^4.8.3"
39
+ "type-fest": "^4.9.0"
40
40
  },
41
- "gitHead": "6b35da161d94f784953d0adecc2d28502052d92a"
41
+ "gitHead": "d6f2aa9bc287768466f23b5340e4e0eecfa30d59"
42
42
  }