npm-package-json-lint
Version:
Configurable linter for package.json files.
2 lines (1 loc) • 2.07 kB
JavaScript
var f=Object.create;var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var b=(t,r)=>{for(var e in r)a(t,e,{get:r[e],enumerable:!0})},h=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of y(r))!P.call(t,i)&&i!==e&&a(t,i,{get:()=>r[i],enumerable:!(n=m(r,i))||n.enumerable});return t};var p=(t,r,e)=>(e=t!=null?f(c(t)):{},h(r||!t||!t.__esModule?a(e,"default",{value:t,enumerable:!0}):e,t)),w=t=>h(a({},"__esModule",{value:!0}),t);var S={};b(S,{lint:()=>x,ruleType:()=>E});module.exports=w(S);var O=p(require("is-plain-obj"));var g=(t,r)=>t.hasOwnProperty(r)?typeof t[r]=="string":!0;var d=p(require("chalk")),u=p(require("log-symbols"));var o=class{constructor(r,e,n,i){this.lintId=r,this.severity=e,this.node=n,this.lintMessage=i}toString(){let r=this.severity==="error"?u.default.error:u.default.warning,e=d.default.cyan.bold(this.lintId),n=d.default.magenta.bold(this.node),i=this.severity==="error"?d.default.red.bold(this.lintMessage):d.default.yellow(this.lintMessage);return`${r} ${e} - node: ${n} - ${i}`}};var l="description-format",s="description",E="object",x=(t,r,e)=>{if(!t.hasOwnProperty(s))return null;let{description:n}=t;if(!g(t,s))return new o(l,r,s,"Type should be a string");if(e.hasOwnProperty("requireCapitalFirstLetter")&&e.requireCapitalFirstLetter&&n.length>0&&n[0]!==n[0].toUpperCase())return new o(l,r,s,`The description should start with a capital letter. It currently starts with ${n[0]}.`);if(e.hasOwnProperty("requireEndingPeriod")&&e.hasOwnProperty("forbidEndingPeriod"))throw new Error("description-format does not support `requireEndingPeriod` and `forbidEndingPeriod` being `true`.");return e.hasOwnProperty("requireEndingPeriod")&&e.requireEndingPeriod&&!n.endsWith(".")?new o(l,r,s,"The description should end with a period."):e.hasOwnProperty("forbidEndingPeriod")&&e.forbidEndingPeriod&&n.endsWith(".")?new o(l,r,s,"The description should not end with a period."):null};0&&(module.exports={lint,ruleType});