UNPKG

tsd-check

Version:
22 lines (21 loc) 766 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); const fs = require("fs"); const utils_1 = require("../utils"); /** * Rule which enforces the use of a `types` property over a `typings` property. * * @param context - The context object. * @returns A list of custom diagnostics. */ exports.default = (context) => { const { pkg } = context; if (!pkg.types && pkg.typings) { const content = fs.readFileSync(path.join(context.cwd, 'package.json'), 'utf8'); return [ Object.assign({ fileName: 'package.json', message: 'Use property `types` instead of `typings`.', severity: 'error' }, utils_1.getJSONPropertyPosition(content, 'typings')) ]; } return []; };