Skip to content

Commit

Permalink
Skip vendor type declaration linting
Browse files Browse the repository at this point in the history
Our vendor directory includes code copied from:

1. https://polyfill.io web service
2. https://www.npmjs.com/package/polyfill-library
3. https://developer.mozilla.org

Feature detection doesn’t necessarily follow completed browser API specifications so we’ll ignore it all as “known working”
  • Loading branch information
colinrotherham committed Dec 15, 2022
1 parent 8026897 commit 86d99c0
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 13 deletions.
2 changes: 2 additions & 0 deletions lib/file-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ const getFullPageExamples = async () => {
// Add metadata (front matter) to each example
const examples = await Promise.all(directories.map(async (exampleName) => {
const templatePath = join(configPaths.fullPageExamples, exampleName, 'index.njk')

// @ts-expect-error "This expression is not callable" due to incorrect types
const { attributes } = fm(await readFile(templatePath, 'utf8'))

return {
Expand Down
3 changes: 2 additions & 1 deletion src/govuk/vendor/polyfills/DOMTokenList.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(undefined) {
// @ts-nocheck
(function (undefined) {

// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
var detect = (
Expand Down
3 changes: 2 additions & 1 deletion src/govuk/vendor/polyfills/Date/now.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(undefined) {
// @ts-nocheck
(function (undefined) {

// Detection from https://github.com/Financial-Times/polyfill-library/blob/v3.111.0/polyfills/Date/now/detect.js
var detect = ('Date' in self && 'now' in self.Date && 'getTime' in self.Date.prototype)
Expand Down
3 changes: 2 additions & 1 deletion src/govuk/vendor/polyfills/Document.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(undefined) {
// @ts-nocheck
(function (undefined) {

// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
var detect = ("Document" in this)
Expand Down
1 change: 1 addition & 0 deletions src/govuk/vendor/polyfills/Element.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import './Document.mjs'

(function(undefined) {
Expand Down
1 change: 1 addition & 0 deletions src/govuk/vendor/polyfills/Element/prototype/classList.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import '../../Object/defineProperty.mjs'
import '../../DOMTokenList.mjs'
import '../../Element.mjs'
Expand Down
1 change: 1 addition & 0 deletions src/govuk/vendor/polyfills/Element/prototype/closest.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import './matches.mjs'

(function(undefined) {
Expand Down
11 changes: 6 additions & 5 deletions src/govuk/vendor/polyfills/Element/prototype/dataset.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import '../../Object/defineProperty.mjs'
import '../../Element.mjs'

Expand All @@ -21,22 +22,22 @@ import '../../Element.mjs'
var element = this;
var attributes = this.attributes;
var map = {};

for (var i = 0; i < attributes.length; i++) {
var attribute = attributes[i];

// This regex has been edited from the original polyfill, to add
// support for period (.) separators in data-* attribute names. These
// are allowed in the HTML spec, but were not covered by the original
// polyfill's regex. We use periods in our i18n implementation.
if (attribute && attribute.name && (/^data-\w[.\w-]*$/).test(attribute.name)) {
var name = attribute.name;
var value = attribute.value;

var propName = name.substr(5).replace(/-./g, function (prop) {
return prop.charAt(1).toUpperCase();
});

// If this browser supports __defineGetter__ and __defineSetter__,
// continue using defineProperty. If not (like IE 8 and below), we use
// a hacky fallback which at least gives an object in the right format
Expand All @@ -60,7 +61,7 @@ import '../../Element.mjs'

}
}

return map;
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/govuk/vendor/polyfills/Element/prototype/matches.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(undefined) {
// @ts-nocheck
(function (undefined) {

// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/matches/detect.js
var detect = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import '../../Object/defineProperty.mjs'
import '../../Element.mjs'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import '../../Object/defineProperty.mjs'
import '../../Element.mjs'

Expand Down
1 change: 1 addition & 0 deletions src/govuk/vendor/polyfills/Event.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import './Window.mjs'
import './Element.mjs'
import './Object/defineProperty.mjs'
Expand Down
1 change: 1 addition & 0 deletions src/govuk/vendor/polyfills/Function/prototype/bind.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import '../../Object/defineProperty.mjs'

(function(undefined) {
Expand Down
3 changes: 2 additions & 1 deletion src/govuk/vendor/polyfills/Object/defineProperty.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(undefined) {
// @ts-nocheck
(function (undefined) {

// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
var detect = (
Expand Down
5 changes: 3 additions & 2 deletions src/govuk/vendor/polyfills/String/prototype/trim.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(function(undefined) {
// @ts-nocheck
(function (undefined) {

// Detection from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
var detect = ('trim' in String.prototype)

if (detect) return

// Polyfill from https://github.com/mdn/content/blob/cf607d68522cd35ee7670782d3ee3a361eaef2e4/files/en-us/web/javascript/reference/global_objects/string/trim/index.md#polyfill
Expand Down
3 changes: 2 additions & 1 deletion src/govuk/vendor/polyfills/Window.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(undefined) {
// @ts-nocheck
(function (undefined) {

// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
var detect = ('Window' in this)
Expand Down

0 comments on commit 86d99c0

Please sign in to comment.