@markuplint/rules 2.0.0 → 2.2.0

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 (47) hide show
  1. package/lib/attr-check.d.ts +8 -19
  2. package/lib/attr-duplication/index.d.ts +1 -1
  3. package/lib/attr-equal-space-after/index.d.ts +1 -1
  4. package/lib/attr-equal-space-before/index.d.ts +1 -1
  5. package/lib/attr-spacing/index.d.ts +3 -3
  6. package/lib/attr-value-quotes/index.d.ts +2 -2
  7. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  8. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  9. package/lib/character-reference/index.d.ts +1 -1
  10. package/lib/class-naming/index.d.ts +1 -1
  11. package/lib/create-message.d.ts +2 -12
  12. package/lib/deprecated-attr/index.d.ts +1 -1
  13. package/lib/deprecated-element/index.d.ts +1 -1
  14. package/lib/disallowed-element/index.d.ts +1 -1
  15. package/lib/doctype/index.d.ts +2 -2
  16. package/lib/end-tag/index.d.ts +1 -1
  17. package/lib/helpers.d.ts +42 -74
  18. package/lib/helpers.js +1 -0
  19. package/lib/id-duplication/index.d.ts +1 -1
  20. package/lib/indentation/index.d.ts +3 -3
  21. package/lib/index.d.ts +62 -147
  22. package/lib/index.js +2 -0
  23. package/lib/ineffective-attr/index.d.ts +1 -1
  24. package/lib/invalid-attr/index.d.ts +12 -16
  25. package/lib/landmark-roles/index.d.ts +3 -3
  26. package/lib/no-boolean-attr-value/index.d.ts +1 -1
  27. package/lib/no-boolean-attr-value/index.js +1 -1
  28. package/lib/no-default-value/index.d.ts +1 -1
  29. package/lib/no-default-value/index.js +3 -3
  30. package/lib/no-hard-code-id/index.d.ts +1 -1
  31. package/lib/no-hard-code-id/index.js +3 -4
  32. package/lib/no-refer-to-non-existent-id/index.d.ts +1 -1
  33. package/lib/no-refer-to-non-existent-id/index.js +12 -12
  34. package/lib/no-use-event-handler-attr/index.d.ts +2 -2
  35. package/lib/permitted-contents/index.d.ts +2 -2
  36. package/lib/permitted-contents/index.js +1 -0
  37. package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +8 -8
  38. package/lib/require-accessible-name/index.d.ts +2 -0
  39. package/lib/require-accessible-name/index.js +22 -0
  40. package/lib/required-attr/index.d.ts +3 -3
  41. package/lib/required-attr/index.js +1 -1
  42. package/lib/required-element/index.d.ts +2 -2
  43. package/lib/required-h1/index.d.ts +3 -3
  44. package/lib/wai-aria/index.d.ts +7 -7
  45. package/package.json +4 -4
  46. package/schema.json +3 -0
  47. package/tsconfig.tsbuildinfo +1 -1
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
2
2
  export default _default;
@@ -26,9 +26,9 @@ exports.default = (0, ml_core_1.createRule)({
26
26
  if (defaultValue === normalizedValue) {
27
27
  report({
28
28
  scope: el,
29
- line: attr.value.startLine,
30
- col: attr.value.startCol,
31
- raw: attr.value.raw,
29
+ line: attr.valueNode.startLine,
30
+ col: attr.valueNode.startCol,
31
+ raw: attr.valueNode.raw,
32
32
  message: t('It is {0}', t('the {0}', 'default value')),
33
33
  });
34
34
  }
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
2
2
  export default _default;
@@ -9,10 +9,9 @@ exports.default = (0, ml_core_1.createRule)({
9
9
  }
10
10
  await document.walkOn('Element', el => {
11
11
  for (const attr of el.attributes) {
12
- if ((attr.attrType === 'html-attr' && !attr.isDynamicValue) ||
13
- (attr.attrType === 'ps-attr' &&
14
- attr.potentialName.toLowerCase() === 'id' &&
15
- attr.valueType !== 'code')) {
12
+ if (attr.potentialName.toLowerCase() === 'id' &&
13
+ ((attr.attrType === 'html-attr' && !attr.isDynamicValue) ||
14
+ (attr.attrType === 'ps-attr' && attr.valueType !== 'code'))) {
16
15
  report({
17
16
  scope: el,
18
17
  line: attr.startLine,
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
2
2
  export default _default;
@@ -51,9 +51,9 @@ exports.default = (0, ml_core_1.createRule)({
51
51
  if (spec.type === 'DOMID' && !idList.has(value)) {
52
52
  report({
53
53
  scope: el,
54
- line: attr.value.startLine,
55
- col: attr.value.startCol,
56
- raw: attr.value.raw,
54
+ line: attr.valueNode.startLine,
55
+ col: attr.valueNode.startCol,
56
+ raw: attr.valueNode.raw,
57
57
  message: t('Missing {0}', t('"{0*}" ID', value)),
58
58
  });
59
59
  }
@@ -66,9 +66,9 @@ exports.default = (0, ml_core_1.createRule)({
66
66
  if (!idList.has(ref)) {
67
67
  report({
68
68
  scope: el,
69
- line: attr.value.startLine,
70
- col: attr.value.startCol,
71
- raw: attr.value.raw,
69
+ line: attr.valueNode.startLine,
70
+ col: attr.valueNode.startCol,
71
+ raw: attr.valueNode.raw,
72
72
  message: t('Missing {0}', t('"{0*}" ID', ref)),
73
73
  });
74
74
  }
@@ -80,9 +80,9 @@ exports.default = (0, ml_core_1.createRule)({
80
80
  if (aria.value === 'ID reference' && !idList.has(value)) {
81
81
  report({
82
82
  scope: el,
83
- line: attr.value.startLine,
84
- col: attr.value.startCol,
85
- raw: attr.value.raw,
83
+ line: attr.valueNode.startLine,
84
+ col: attr.valueNode.startCol,
85
+ raw: attr.valueNode.raw,
86
86
  message: t('Missing {0}', t('"{0*}" ID', value)),
87
87
  });
88
88
  }
@@ -95,9 +95,9 @@ exports.default = (0, ml_core_1.createRule)({
95
95
  if (!idList.has(ref)) {
96
96
  report({
97
97
  scope: el,
98
- line: attr.value.startLine,
99
- col: attr.value.startCol,
100
- raw: attr.value.raw,
98
+ line: attr.valueNode.startLine,
99
+ col: attr.valueNode.startCol,
100
+ raw: attr.valueNode.raw,
101
101
  message: t('Missing {0}', t('"{0*}" ID', ref)),
102
102
  });
103
103
  }
@@ -1,5 +1,5 @@
1
1
  declare type Options = {
2
- ignore?: string | string[];
2
+ ignore?: string | string[];
3
3
  };
4
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
4
+ declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Options>;
5
5
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import type { PermittedStructuresSchema } from '@markuplint/ml-spec';
2
2
  declare type Options = {
3
- ignoreHasMutableChildren: boolean;
3
+ ignoreHasMutableChildren: boolean;
4
4
  };
5
- declare const _default: import('@markuplint/ml-core').RuleSeed<PermittedStructuresSchema[], Options>;
5
+ declare const _default: import("@markuplint/ml-core").RuleSeed<PermittedStructuresSchema[], Options>;
6
6
  export default _default;
@@ -136,6 +136,7 @@ exports.default = (0, ml_core_1.createRule)({
136
136
  function normalization(nodes, ownNS, evalCustomElement) {
137
137
  return nodes
138
138
  .map(node => {
139
+ // FIXME: https://github.com/markuplint/markuplint/issues/388
139
140
  if (!evalCustomElement && node.type === 'Element' && node.isCustomElement) {
140
141
  return '';
141
142
  }
@@ -1,11 +1,11 @@
1
1
  import type { PermittedContent } from '@markuplint/ml-spec';
2
2
  export default class ExpGenerator {
3
- private _id;
4
- private _idCounter;
5
- constructor(_id: number);
6
- specToRegExp(contentRule: PermittedContent[] | boolean, parentExp?: RegExp | null, ownNS?: string | null): RegExp;
7
- private _toPattern;
8
- private _interleavePattern;
9
- private _targetTags;
10
- private _resolveTags;
3
+ private _id;
4
+ private _idCounter;
5
+ constructor(_id: number);
6
+ specToRegExp(contentRule: PermittedContent[] | boolean, parentExp?: RegExp | null, ownNS?: string | null): RegExp;
7
+ private _toPattern;
8
+ private _interleavePattern;
9
+ private _targetTags;
10
+ private _resolveTags;
11
11
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, null>;
2
+ export default _default;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ml_core_1 = require("@markuplint/ml-core");
4
+ const helpers_1 = require("../helpers");
5
+ exports.default = (0, ml_core_1.createRule)({
6
+ async verify({ document, report, t }) {
7
+ await document.walkOn('Element', el => {
8
+ const role = (0, helpers_1.getComputedRole)(document.specs, el);
9
+ if (!role) {
10
+ return;
11
+ }
12
+ const roleSpec = (0, helpers_1.getRoleSpec)(document.specs, role.name);
13
+ if (!roleSpec || !roleSpec.accessibleNameRequired) {
14
+ return;
15
+ }
16
+ const hasAccessibleName = !!el.getAccessibleName().trim();
17
+ if (!hasAccessibleName) {
18
+ report({ scope: el, message: t('Require {0}', 'accessible name') });
19
+ }
20
+ });
21
+ },
22
+ });
@@ -1,7 +1,7 @@
1
1
  declare type RequiredAttributes = string | (string | Attr)[];
2
2
  declare type Attr = {
3
- name: string;
4
- value: string | string[];
3
+ name: string;
4
+ value: string | string[];
5
5
  };
6
- declare const _default: import('@markuplint/ml-core').RuleSeed<RequiredAttributes, null>;
6
+ declare const _default: import("@markuplint/ml-core").RuleSeed<RequiredAttributes, null>;
7
7
  export default _default;
@@ -80,7 +80,7 @@ exports.default = (0, ml_core_1.createRule)({
80
80
  const expects = spec.values.length === 1 ? t(spec.values) : t('either {0}', t(spec.values));
81
81
  const message = t('{0} expects {1}', t('the "{0*}" {1}', spec.name, 'attribute'), expects);
82
82
  const attrToken = node.getAttributeToken(spec.name);
83
- const valueToken = ((_a = attrToken[0]) === null || _a === void 0 ? void 0 : _a.attrType) === 'html-attr' ? attrToken[0].value : null;
83
+ const valueToken = ((_a = attrToken[0]) === null || _a === void 0 ? void 0 : _a.attrType) === 'html-attr' ? attrToken[0].valueNode : null;
84
84
  const token = valueToken || attrToken[0];
85
85
  report({
86
86
  scope: {
@@ -1,5 +1,5 @@
1
1
  declare type Options = {
2
- ignoreHasMutableContents?: boolean;
2
+ ignoreHasMutableContents?: boolean;
3
3
  };
4
- declare const _default: import('@markuplint/ml-core').RuleSeed<string[], Options>;
4
+ declare const _default: import("@markuplint/ml-core").RuleSeed<string[], Options>;
5
5
  export default _default;
@@ -1,6 +1,6 @@
1
1
  export interface Options {
2
- 'expected-once'?: boolean;
3
- 'in-document-fragment'?: boolean;
2
+ 'expected-once'?: boolean;
3
+ 'in-document-fragment'?: boolean;
4
4
  }
5
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
5
+ declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Options>;
6
6
  export default _default;
@@ -1,10 +1,10 @@
1
1
  declare type Options = {
2
- checkingValue?: boolean;
3
- checkingDeprecatedProps?: boolean;
4
- permittedAriaRoles?: boolean;
5
- disallowSetImplicitRole?: boolean;
6
- disallowSetImplicitProps?: boolean;
7
- disallowDefaultValue?: boolean;
2
+ checkingValue?: boolean;
3
+ checkingDeprecatedProps?: boolean;
4
+ permittedAriaRoles?: boolean;
5
+ disallowSetImplicitRole?: boolean;
6
+ disallowSetImplicitProps?: boolean;
7
+ disallowDefaultValue?: boolean;
8
8
  };
9
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
9
+ declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Options>;
10
10
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/rules",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Rules for markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -17,8 +17,8 @@
17
17
  "clean": "tsc --build --clean"
18
18
  },
19
19
  "dependencies": {
20
- "@markuplint/html-spec": "2.0.0",
21
- "@markuplint/ml-core": "2.0.0",
20
+ "@markuplint/html-spec": "^2.2.0",
21
+ "@markuplint/ml-core": "^2.1.0",
22
22
  "@markuplint/ml-spec": "2.0.0",
23
23
  "@markuplint/types": "2.0.0",
24
24
  "debug": "^4.3.3",
@@ -27,5 +27,5 @@
27
27
  "devDependencies": {
28
28
  "@types/debug": "^4.1.7"
29
29
  },
30
- "gitHead": "de81fc514acdf472f87184e3499e9364258f9b66"
30
+ "gitHead": "b76084dbdb538119a29fd07b19110ef7d3a44670"
31
31
  }
package/schema.json CHANGED
@@ -81,6 +81,9 @@
81
81
  "permitted-contents": {
82
82
  "$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/permitted-contents/schema.json"
83
83
  },
84
+ "require-accessible-name": {
85
+ "$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/require-accessible-name/schema.json"
86
+ },
84
87
  "required-attr": {
85
88
  "$ref": "https://raw.githubusercontent.com/markuplint/markuplint/main/packages/%40markuplint/rules/src/required-attr/schema.json"
86
89
  },