eslint-config-shiny
Version:
An eslint config that makes your code so clean and polished that it shines!
2 lines (1 loc) • 4.15 kB
JavaScript
import J from"@stylistic/eslint-plugin-js";import w from"@stylistic/eslint-plugin-ts";import P from"eslint-plugin-perfectionist";import{dirname as g,join as m,resolve as h}from"node:path";import{fileURLToPath as x}from"node:url";import f from"strip-json-comments";async function i(r){return JSON.parse(f((await r.readFile()).toString()))}import{open as u}from"node:fs/promises";async function p(r,e){try{return await u(r,e)}catch{return}}var o=class r{_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 p(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 r(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 n=class{currentPJPath;handlers;constructor(){this.handlers=new Map,this.currentPJPath=m(g(x(import.meta.url)),"..","package.json")}async get(e){let t=this.handlers;if(t.has(e))return t.get(e);let a=await o.parse(e);return t.set(e,a),a}async getCurrentPackage(){return this.get(this.currentPJPath)}async getCwd(){return await this.get(m(y,"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 l="never",s="always",c="field",d="method";var y=process.cwd(),N=new n,D=new AbortController;var U={extends:[P.configs["recommended-natural"]],name:"format",plugins:{styleJs:J,styleTs:w},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,"styleJs/array-bracket-spacing":1,"styleJs/computed-property-spacing":1,"styleJs/dot-location":[1,"property"],"styleJs/eol-last":1,"styleJs/generator-star-spacing":[1,"after"],"styleJs/implicit-arrow-linebreak":1,"styleJs/multiline-comment-style":1,"styleJs/new-parens":1,"styleJs/no-confusing-arrow":1,"styleJs/no-floating-decimal":1,"styleJs/no-mixed-spaces-and-tabs":[1,"smart-tabs"],"styleJs/no-multi-spaces":1,"styleJs/no-multiple-empty-lines":1,"styleJs/no-trailing-spaces":1,"styleJs/no-whitespace-before-property":1,"styleJs/nonblock-statement-body-position":1,"styleJs/rest-spread-spacing":[1,l],"styleJs/space-in-parens":1,"styleJs/space-unary-ops":[1,{nonwords:!1,words:!0}],"styleJs/spaced-comment":[1,s],"styleJs/switch-colon-spacing":1,"styleJs/template-curly-spacing":1,"styleJs/template-tag-spacing":1,"styleJs/wrap-iife":[1,"inside"],"styleJs/yield-star-spacing":[1,"after"],"styleTs/brace-style":1,"styleTs/function-call-spacing":1,"styleTs/key-spacing":1,"styleTs/keyword-spacing":1,"styleTs/lines-between-class-members":[1,{enforce:[{blankLine:l,next:c,prev:c},{blankLine:s,next:d,prev:c},{blankLine:s,next:d,prev:d}]}],"styleTs/space-before-blocks":1,"styleTs/space-before-function-paren":[1,{anonymous:s,asyncArrow:s,named:l}],"styleTs/space-infix-ops":1,"styleTs/type-annotation-spacing":1}]};export{U as config};