eslint-config-shiny
Version:
An eslint config that makes your code so clean and polished that it shines!
2 lines (1 loc) • 3.98 kB
JavaScript
import P from"@stylistic/eslint-plugin";import x from"eslint-plugin-perfectionist";import{dirname as u,join as y,resolve as h}from"node:path";import{fileURLToPath as w}from"node:url";import{safeGetFileHandle as g}from"node-comb";import{parseJson as d}from"compresso";import f from"strip-json-comments";async function i(s){return d(f((await s.readFile()).toString()))}var n=class s{_entryFile;_typesFolder;deps;meta;bugUrl;description;homepage;keywords;name;version;constructor(e){this.meta=e,this.name=e.name,this.version=e.version,this.description=e.description}isCJS(){return this.meta.type==="commonjs"}isModule(){return this.meta.type==="module"}static async parse(e){let t=await g(e,"r+");if(!t)throw new Error(`Couldn't find package.json file for path "${e}"!`);let a=await i(t);return await t.close(),new s(a)}get dependencies(){return this.deps?this.deps:this.deps=Object.keys(this.meta.dependencies??[])}get entryFile(){if(this._entryFile)return this._entryFile;let e=this.meta;return this._entryFile=e.main??e.exports?.default??"index.js"}get typesFolder(){if(this._typesFolder)return this._typesFolder;let e=this.meta;return this._typesFolder=e.types??e.exports?.types??"index.d.ts"}};var o=class{currentPJPath;handlers;constructor(){this.handlers=new Map,this.currentPJPath=y(u(w(import.meta.url)),"..","package.json")}async get(e){let t=this.handlers;if(t.has(e))return t.get(e);let a=await n.parse(e);return t.set(e,a),a}async getCurrentPackage(){return this.get(this.currentPJPath)}async getCwd(){return await this.get(y(m,"package.json"))}async getModule(e){try{return await this.get(h("node_modules",e,"package.json"))}catch{throw new Error(`Couldn't find node module ${e}.`)}}};var p="never",r="always",l="field",c="method";var m=process.cwd(),T=new o;function k(s){return{extends:[x.configs["recommended-natural"]],name:"format",plugins:{style:P},rules:[{"perfectionist/sort-classes":[2,{groups:["index-signature","static-property","static-block",["protected-property","protected-accessor-property"],["private-property","private-accessor-property"],["property","accessor-property"],"constructor","protected-method","private-method","method","static-method",["get-method","set-method"],"unknown"]}],"perfectionist/sort-imports":["error",{customGroups:{type:{react:["^react$","^react-."]},value:{react:["^react$","^react-."]}},groups:["react","builtin","builtin-type","external-type","external",["internal","internal-type"],["parent-type","sibling-type","index-type"],["parent","sibling","index"],"side-effect","object","style","unknown"],newlinesBetween:"ignore",order:"asc",type:"natural"}],"perfectionist/sort-intersection-types":0,"perfectionist/sort-jsx-props":0,"perfectionist/sort-union-types":0,"style/array-bracket-spacing":1,"style/computed-property-spacing":1,"style/dot-location":[1,"property"],"style/eol-last":1,"style/generator-star-spacing":[1,"after"],"style/implicit-arrow-linebreak":1,"style/multiline-comment-style":1,"style/new-parens":1,"style/no-confusing-arrow":1,"style/no-floating-decimal":1,"style/no-mixed-spaces-and-tabs":[1,"smart-tabs"],"style/no-multi-spaces":1,"style/no-multiple-empty-lines":1,"style/no-trailing-spaces":1,"style/no-whitespace-before-property":1,"style/nonblock-statement-body-position":1,"style/rest-spread-spacing":[1,p],"style/space-in-parens":1,"style/space-unary-ops":[1,{nonwords:!1,words:!0}],"style/spaced-comment":[1,r],"style/switch-colon-spacing":1,"style/template-curly-spacing":1,"style/template-tag-spacing":1,"style/wrap-iife":[1,"inside"],"style/yield-star-spacing":1,"style/brace-style":1,"style/function-call-spacing":1,"style/key-spacing":1,"style/keyword-spacing":1,"style/lines-between-class-members":[1,{enforce:[{blankLine:p,next:l,prev:l},{blankLine:r,next:c,prev:l},{blankLine:r,next:c,prev:c}]}],"style/space-before-blocks":1,"style/space-before-function-paren":[1,{anonymous:r,asyncArrow:r,named:p}],"style/space-infix-ops":1,"style/type-annotation-spacing":1}]}}export{k as default};