@fulldecent/nice-checkers-plugin 1.3.0 → 1.3.2

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.
package/README.md CHANGED
@@ -447,6 +447,41 @@ Note that these sources we reference have a conflict. One says that you may use
447
447
  - [Google: specify alternate language pages](https://developers.google.com/search/docs/specialty/international/localized-versions)
448
448
  - [W3C: link type 'alternate'](https://html.spec.whatwg.org/multipage/links.html#link-type-alternate)
449
449
 
450
+ ## Disabled html-validate core rules
451
+
452
+ `nice-checkers-plugin:recommended` explicitly turns off the following built-in html-validate rules because they conflict with common HTML minification tools.
453
+
454
+ ### `no-implicit-button-type` and `no-implicit-input-type`
455
+
456
+ HTML minifiers such as [`@minify-html/node`](https://github.com/wilsonzlin/minify-html) strip the `type` attribute from `<button>` and `<input>` elements when it equals the HTML-spec default value (e.g. `type="submit"` on `<button>`, `type="text"` on `<input>`). This is valid per the spec and reduces page size, but it causes false-positive warnings from these two core rules when validating **minified** output.
457
+
458
+ ```js
459
+ import { minify } from '@minify-html/node'
460
+
461
+ const html = '<button type="submit">Go</button><input type="text" name="q">'
462
+ const minified = minify(Buffer.from(html), {
463
+ /* options */
464
+ })
465
+ // → "<button>Go</button><input name=q>"
466
+ // type="submit" and type="text" are stripped as they are HTML defaults
467
+ ```
468
+
469
+ Extending `nice-checkers-plugin:recommended` disables both rules so that projects validating minified output do not need a workaround.
470
+
471
+ If you author your HTML by hand (i.e. you are **not** validating minified output) and want to enforce these rules, you can re-enable them explicitly in your own configuration:
472
+
473
+ ```json
474
+ {
475
+ "extends": ["htmlvalidate:recommended", "nice-checkers-plugin:recommended"],
476
+ "rules": {
477
+ "no-implicit-button-type": "error",
478
+ "no-implicit-input-type": "error"
479
+ }
480
+ }
481
+ ```
482
+
483
+ See [issue #23](https://github.com/fulldecent/html-validate-nice-checkers/issues/23) for the full discussion.
484
+
450
485
  ## Development
451
486
 
452
487
  This package is built with TypeScript and supports both ESM and CommonJS module systems. Thank you for contributing improvements to this project!
package/dist/index.cjs CHANGED
@@ -519,6 +519,6 @@ E.g. Cheaper and slower: $5 in 5-7 days
519
519
  or Fast and expensive: $15 in 1-2 days.`,"rdfs:label":"OfferShippingDetails","rdfs:subClassOf":{"@id":"schema:StructuredValue"},"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/2506"}},{"@id":"schema:SurgicalProcedure","@type":"rdfs:Class","owl:equivalentClass":{"@id":"http://purl.bioontology.org/ontology/SNOMEDCT/387713003"},"rdfs:comment":"A medical procedure involving an incision with instruments; performed for diagnose, or therapeutic purposes.","rdfs:label":"SurgicalProcedure","rdfs:subClassOf":{"@id":"schema:MedicalProcedure"},"schema:isPartOf":{"@id":"https://health-lifesci.schema.org"}},{"@id":"schema:hasVariant","@type":"rdf:Property","rdfs:comment":"Indicates a [[Product]] that is a member of this [[ProductGroup]] (or [[ProductModel]]).","rdfs:label":"hasVariant","schema:domainIncludes":{"@id":"schema:ProductGroup"},"schema:inverseOf":{"@id":"schema:isVariantOf"},"schema:isPartOf":{"@id":"https://pending.schema.org"},"schema:rangeIncludes":{"@id":"schema:Product"},"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/1797"}},{"@id":"schema:remainingAttendeeCapacity","@type":"rdf:Property","rdfs:comment":"The number of attendee places for an event that remain unallocated.","rdfs:label":"remainingAttendeeCapacity","schema:domainIncludes":{"@id":"schema:Event"},"schema:rangeIncludes":{"@id":"schema:Integer"}},{"@id":"schema:paymentMethod","@type":"rdf:Property","rdfs:comment":"The name of the credit card or other method of payment for the order.","rdfs:label":"paymentMethod","schema:domainIncludes":[{"@id":"schema:Order"},{"@id":"schema:Invoice"}],"schema:rangeIncludes":[{"@id":"schema:Text"},{"@id":"schema:PaymentMethod"}],"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/3537"}},{"@id":"schema:ListPrice","@type":"schema:PriceTypeEnumeration","rdfs:comment":"Represents the list price of an offered product. Typically the same as the [MSRP](https://schema.org/MSRP).","rdfs:label":"ListPrice","schema:isPartOf":{"@id":"https://pending.schema.org"},"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/2712"}},{"@id":"schema:acceptsReservations","@type":"rdf:Property","rdfs:comment":"Indicates whether a FoodEstablishment accepts reservations. Values can be Boolean, an URL at which reservations can be made or (for backwards compatibility) the strings ```Yes``` or ```No```.","rdfs:label":"acceptsReservations","schema:domainIncludes":{"@id":"schema:FoodEstablishment"},"schema:rangeIncludes":[{"@id":"schema:Text"},{"@id":"schema:URL"},{"@id":"schema:Boolean"}]},{"@id":"schema:PatientExperienceHealthAspect","@type":"schema:HealthAspectEnumeration","rdfs:comment":"Content about the real life experience of patients or people that have lived a similar experience about the topic. May be forums, topics, Q-and-A and related material.","rdfs:label":"PatientExperienceHealthAspect","schema:isPartOf":{"@id":"https://pending.schema.org"},"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/2374"}},{"@id":"schema:customerRemorseReturnFees","@type":"rdf:Property","rdfs:comment":"The type of return fees if the product is returned due to customer remorse.","rdfs:label":"customerRemorseReturnFees","schema:domainIncludes":{"@id":"schema:MerchantReturnPolicy"},"schema:isPartOf":{"@id":"https://pending.schema.org"},"schema:rangeIncludes":{"@id":"schema:ReturnFeesEnumeration"},"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/2880"}},{"@id":"schema:renegotiableLoan","@type":"rdf:Property","rdfs:comment":"Whether the terms for payment of interest can be renegotiated during the life of the loan.","rdfs:label":"renegotiableLoan","schema:contributor":{"@id":"https://schema.org/docs/collab/FIBO"},"schema:domainIncludes":{"@id":"schema:LoanOrCredit"},"schema:isPartOf":{"@id":"https://pending.schema.org"},"schema:rangeIncludes":{"@id":"schema:Boolean"},"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/1253"}},{"@id":"schema:BodyMeasurementNeck","@type":"schema:BodyMeasurementTypeEnumeration","rdfs:comment":"Girth of neck. Used, for example, to fit shirts.","rdfs:label":"BodyMeasurementNeck","schema:isPartOf":{"@id":"https://pending.schema.org"},"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/2811"}},{"@id":"schema:warranty","@type":"rdf:Property","rdfs:comment":"The warranty promise(s) included in the offer.","rdfs:label":"warranty","schema:contributor":{"@id":"https://schema.org/docs/collab/GoodRelationsTerms"},"schema:domainIncludes":[{"@id":"schema:Offer"},{"@id":"schema:Demand"}],"schema:rangeIncludes":{"@id":"schema:WarrantyPromise"}},{"@id":"schema:broadcastOfEvent","@type":"rdf:Property","rdfs:comment":"The event being broadcast such as a sporting event or awards ceremony.","rdfs:label":"broadcastOfEvent","schema:domainIncludes":{"@id":"schema:BroadcastEvent"},"schema:rangeIncludes":{"@id":"schema:Event"}},{"@id":"schema:DrugCostCategory","@type":"rdfs:Class","rdfs:comment":"Enumerated categories of medical drug costs.","rdfs:label":"DrugCostCategory","rdfs:subClassOf":{"@id":"schema:MedicalEnumeration"},"schema:isPartOf":{"@id":"https://health-lifesci.schema.org"}},{"@id":"schema:LimitedByGuaranteeCharity","@type":"schema:UKNonprofitType","rdfs:comment":"LimitedByGuaranteeCharity: Non-profit type referring to a charitable company that is limited by guarantee (UK).","rdfs:label":"LimitedByGuaranteeCharity","schema:isPartOf":{"@id":"https://pending.schema.org"},"schema:source":{"@id":"https://github.com/schemaorg/schemaorg/issues/2543"}},{"@id":"schema:director","@type":"rdf:Property","rdfs:comment":"A director of e.g. TV, radio, movie, video gaming etc. content, or of an event. Directors can be associated with individual items or with a series, episode, clip.","rdfs:label":"director","schema:domainIncludes":[{"@id":"schema:Clip"},{"@id":"schema:CreativeWorkSeason"},{"@id":"schema:Event"},{"@id":"schema:VideoObject"},{"@id":"schema:MovieSeries"},{"@id":"schema:TVSeries"},{"@id":"schema:VideoGame"},{"@id":"schema:Movie"},{"@id":"schema:RadioSeries"},{"@id":"schema:Episode"},{"@id":"schema:VideoGameSeries"}],"schema:rangeIncludes":{"@id":"schema:Person"}},{"@id":"schema:AutomatedTeller","@type":"rdfs:Class","rdfs:comment":"ATM/cash machine.","rdfs:label":"AutomatedTeller","rdfs:subClassOf":{"@id":"schema:FinancialService"}},{"@id":"schema:HotelRoom","@type":"rdfs:Class","rdfs:comment":`A hotel room is a single room in a hotel.
520
520
  <br /><br />
521
521
  See also the <a href="/docs/hotels.html">dedicated document on the use of schema.org for marking up hotels and other forms of accommodations</a>.
522
- `,"rdfs:label":"HotelRoom","rdfs:subClassOf":{"@id":"schema:Room"},"schema:contributor":{"@id":"https://schema.org/docs/collab/STI_Accommodation_Ontology"}},{"@id":"schema:PercutaneousProcedure","@type":"schema:MedicalProcedureType","rdfs:comment":"A type of medical procedure that involves percutaneous techniques, where access to organs or tissue is achieved via needle-puncture of the skin. For example, catheter-based procedures like stent delivery.","rdfs:label":"PercutaneousProcedure","schema:isPartOf":{"@id":"https://health-lifesci.schema.org"}}]};var J=class J extends htmlValidate.Rule{constructor(){super();this.validClasses=new Set;this.validProperties=new Set;try{let e=L["@context"],s=e.rdfs+"Class",i=e.rdf+"Property";if(L["@graph"])for(let r of L["@graph"]){let t=Array.isArray(r["@type"])?r["@type"]:[r["@type"]];(t.includes("rdfs:Class")||t.includes(s))&&this.validClasses.add(r["rdfs:label"]),(t.includes("rdf:Property")||t.includes(i))&&this.validProperties.add(r["rdfs:label"]);}if(this.validClasses.size===0||this.validProperties.size===0)throw new Error("Schema loading resulted in zero classes or properties. The vocabulary format may have changed.")}catch(e){throw new Error(`[SchemaOrgJsonLdRule] CRITICAL: Failed to load or process schema: ${e.message}`)}}documentation(){return {description:"Validates JSON-LD against the bundled Schema.org vocabulary.",url:"https://github.com/fulldecent/html-validate-nice-checkers/blob/main/README.md#schema-org-json-ld"}}setup(){this.on("element:ready",e=>this.elementReady(e));}elementReady(e){let{target:s}=e;if(s.tagName!=="script"||s.getAttribute("type")?.value!=="application/ld+json")return;let r=s.textContent;if(!r||r.trim()==="")return;let t;try{t=JSON.parse(r);}catch(o){this.report({node:s,message:`Invalid JSON syntax: ${o.message}`});return}this.validateSchemaObject(t,s,true);}validateSchemaObject(e,s,i){if(Array.isArray(e)){e.forEach(t=>this.validateSchemaObject(t,s,i));return}if(typeof e!="object"||e===null)return;if(i&&e["@graph"]&&Array.isArray(e["@graph"])){this.validateSchemaObject(e["@graph"],s,true);return}let r=e["@type"];if(i&&!r){this.report({node:s,message:'Top-level JSON-LD object is missing required "@type" property.'});return}if(r){let t=Array.isArray(r)?r:[r];for(let o of t)this.validClasses.has(o)||this.report({node:s,message:`Schema.org type "${o}" is not a valid class.`});}for(let t in e){if(t.startsWith("@"))continue;this.validProperties.has(t)||this.report({node:s,message:`Schema.org property "${t}" is not a valid property.`});let o=e[t];typeof o=="object"&&o!==null&&this.validateSchemaObject(o,s,false);}}};d(J,"SchemaOrgJsonLdRule");var E=J;var Se={name:"nice-checkers-plugin",rules:{"nice-checkers/alternate-language-url":b,"nice-checkers/alternate-language-links":P,"nice-checkers/canonical-link":I,"nice-checkers/external-links":C,"nice-checkers/https-links":O,"nice-checkers/internal-links":T,"nice-checkers/latest-packages":A,"nice-checkers/match-regex":w,"nice-checkers/mailto-awesome":S,"nice-checkers/no-jquery":k,"nice-checkers/schema-org-json-ld":E},configs:{recommended:{rules:{"nice-checkers/alternate-language-url":["error"],"nice-checkers/alternate-language-links":["error"],"nice-checkers/canonical-link":["error"],"nice-checkers/external-links":["error"],"nice-checkers/https-links":["error"],"nice-checkers/internal-links":["error"],"nice-checkers/latest-packages":["warn"],"nice-checkers/match-regex":["off"],"nice-checkers/mailto-awesome":["error"],"nice-checkers/no-jquery":["error"],"nice-checkers/schema-org-json-ld":["error"]}}}},zs=Se;
522
+ `,"rdfs:label":"HotelRoom","rdfs:subClassOf":{"@id":"schema:Room"},"schema:contributor":{"@id":"https://schema.org/docs/collab/STI_Accommodation_Ontology"}},{"@id":"schema:PercutaneousProcedure","@type":"schema:MedicalProcedureType","rdfs:comment":"A type of medical procedure that involves percutaneous techniques, where access to organs or tissue is achieved via needle-puncture of the skin. For example, catheter-based procedures like stent delivery.","rdfs:label":"PercutaneousProcedure","schema:isPartOf":{"@id":"https://health-lifesci.schema.org"}}]};var J=class J extends htmlValidate.Rule{constructor(){super();this.validClasses=new Set;this.validProperties=new Set;try{let e=L["@context"],s=e.rdfs+"Class",i=e.rdf+"Property";if(L["@graph"])for(let r of L["@graph"]){let t=Array.isArray(r["@type"])?r["@type"]:[r["@type"]];(t.includes("rdfs:Class")||t.includes(s))&&this.validClasses.add(r["rdfs:label"]),(t.includes("rdf:Property")||t.includes(i))&&this.validProperties.add(r["rdfs:label"]);}if(this.validClasses.size===0||this.validProperties.size===0)throw new Error("Schema loading resulted in zero classes or properties. The vocabulary format may have changed.")}catch(e){throw new Error(`[SchemaOrgJsonLdRule] CRITICAL: Failed to load or process schema: ${e.message}`)}}documentation(){return {description:"Validates JSON-LD against the bundled Schema.org vocabulary.",url:"https://github.com/fulldecent/html-validate-nice-checkers/blob/main/README.md#schema-org-json-ld"}}setup(){this.on("element:ready",e=>this.elementReady(e));}elementReady(e){let{target:s}=e;if(s.tagName!=="script"||s.getAttribute("type")?.value!=="application/ld+json")return;let r=s.textContent;if(!r||r.trim()==="")return;let t;try{t=JSON.parse(r);}catch(o){this.report({node:s,message:`Invalid JSON syntax: ${o.message}`});return}this.validateSchemaObject(t,s,true);}validateSchemaObject(e,s,i){if(Array.isArray(e)){e.forEach(t=>this.validateSchemaObject(t,s,i));return}if(typeof e!="object"||e===null)return;if(i&&e["@graph"]&&Array.isArray(e["@graph"])){this.validateSchemaObject(e["@graph"],s,true);return}let r=e["@type"];if(i&&!r){this.report({node:s,message:'Top-level JSON-LD object is missing required "@type" property.'});return}if(r){let t=Array.isArray(r)?r:[r];for(let o of t)this.validClasses.has(o)||this.report({node:s,message:`Schema.org type "${o}" is not a valid class.`});}for(let t in e){if(t.startsWith("@"))continue;this.validProperties.has(t)||this.report({node:s,message:`Schema.org property "${t}" is not a valid property.`});let o=e[t];typeof o=="object"&&o!==null&&this.validateSchemaObject(o,s,false);}}};d(J,"SchemaOrgJsonLdRule");var E=J;var Se={name:"nice-checkers-plugin",rules:{"nice-checkers/alternate-language-url":b,"nice-checkers/alternate-language-links":P,"nice-checkers/canonical-link":I,"nice-checkers/external-links":C,"nice-checkers/https-links":O,"nice-checkers/internal-links":T,"nice-checkers/latest-packages":A,"nice-checkers/match-regex":w,"nice-checkers/mailto-awesome":S,"nice-checkers/no-jquery":k,"nice-checkers/schema-org-json-ld":E},configs:{recommended:{rules:{"nice-checkers/alternate-language-url":["error"],"nice-checkers/alternate-language-links":["error"],"nice-checkers/canonical-link":["error"],"nice-checkers/external-links":["error"],"nice-checkers/https-links":["error"],"nice-checkers/internal-links":["error"],"nice-checkers/latest-packages":["warn"],"nice-checkers/match-regex":["off"],"nice-checkers/mailto-awesome":["error"],"nice-checkers/no-jquery":["error"],"nice-checkers/schema-org-json-ld":["error"],"no-implicit-button-type":["off"],"no-implicit-input-type":["off"]}}}},zs=Se;
523
523
  module.exports=zs;//# sourceMappingURL=index.cjs.map
524
524
  //# sourceMappingURL=index.cjs.map