diff --git a/src/DeviceDescriptors.js b/src/DeviceDescriptors.ts similarity index 98% rename from src/DeviceDescriptors.js rename to src/DeviceDescriptors.ts index 5d586d779a455..945e5cadf7f47 100644 --- a/src/DeviceDescriptors.js +++ b/src/DeviceDescriptors.ts @@ -14,7 +14,20 @@ * limitations under the License. */ -module.exports = [ +interface Device { + name: string; + userAgent: string; + viewport: { + width: number; + height: number; + deviceScaleFactor: number; + isMobile: boolean; + hasTouch: boolean; + isLandscape: boolean; + }; +}; + +const devices: Device[] = [ { 'name': 'Blackberry PlayBook', 'userAgent': 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/7.2.1.0 Safari/536.2+', @@ -868,5 +881,15 @@ module.exports = [ } } ]; -for (const device of module.exports) - module.exports[device.name] = device; + +type DevicesMap = { + [name: string]: Device; +}; + +const devicesMap: DevicesMap = {}; + +for (const device of devices) { + devicesMap[device.name] = device; +} + +export = devicesMap; diff --git a/tsconfig.json b/tsconfig.json index 815fab9b1be10..baf9d96a5a493 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,8 @@ "checkJs": true, "outDir": "./lib", "target": "ESNext", - "moduleResolution": "node" + "moduleResolution": "node", + "module": "CommonJS" }, "include": [ "src" diff --git a/utils/doclint/cli.js b/utils/doclint/cli.js index ed58a4b43a5cf..96eb000a723f5 100755 --- a/utils/doclint/cli.js +++ b/utils/doclint/cli.js @@ -36,31 +36,29 @@ async function run() { let changedFiles = false; // Documentation checks. - { - const readme = await Source.readFile(path.join(PROJECT_DIR, 'README.md')); - const contributing = await Source.readFile(path.join(PROJECT_DIR, 'CONTRIBUTING.md')); - const api = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'api.md')); - const troubleshooting = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'troubleshooting.md')); - const mdSources = [readme, api, troubleshooting, contributing]; + const readme = await Source.readFile(path.join(PROJECT_DIR, 'README.md')); + const contributing = await Source.readFile(path.join(PROJECT_DIR, 'CONTRIBUTING.md')); + const api = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'api.md')); + const troubleshooting = await Source.readFile(path.join(PROJECT_DIR, 'docs', 'troubleshooting.md')); + const mdSources = [readme, api, troubleshooting, contributing]; - const preprocessor = require('./preprocessor'); - messages.push(...await preprocessor.runCommands(mdSources, VERSION)); - messages.push(...await preprocessor.ensureReleasedAPILinks([readme], VERSION)); + const preprocessor = require('./preprocessor'); + messages.push(...await preprocessor.runCommands(mdSources, VERSION)); + messages.push(...await preprocessor.ensureReleasedAPILinks([readme], VERSION)); - const browser = await puppeteer.launch(); - const page = await browser.newPage(); - const checkPublicAPI = require('./check_public_api'); - const jsSources = await Source.readdir(path.join(PROJECT_DIR, 'lib')); - messages.push(...await checkPublicAPI(page, mdSources, jsSources)); + const browser = await puppeteer.launch(); + const page = await browser.newPage(); + const checkPublicAPI = require('./check_public_api'); + const jsSources = await Source.readdir(path.join(PROJECT_DIR, 'lib')); + messages.push(...await checkPublicAPI(page, mdSources, jsSources)); - await browser.close(); + await browser.close(); - for (const source of mdSources) { - if (!source.hasUpdatedText()) - continue; - await source.save(); - changedFiles = true; - } + for (const source of mdSources) { + if (!source.hasUpdatedText()) + continue; + await source.save(); + changedFiles = true; } // Report results.