UNPKG

eslint-config-shiny

Version:

An eslint config that makes your code so clean and polished that it shines!

2 lines (1 loc) 4.09 kB
import P from"@eslint-react/eslint-plugin";import w from"@stylistic/eslint-plugin";import m from"eslint-plugin-jsx-a11y";import k from"eslint-plugin-react-hook-form";import J from"eslint-plugin-react-hooks";import v from"eslint-plugin-react-perf";import F from"eslint-plugin-react-prefer-function-component";import b from"eslint-plugin-react-redux";import C from"eslint-plugin-react-refresh";import E from"eslint-plugin-validate-jsx-nesting";import{dirname as y,join as l,resolve as h}from"node:path";import{fileURLToPath as j}from"node:url";import{safeGetFileHandle as x}from"node-comb";import{parseJson as f}from"compresso";import u from"strip-json-comments";async function a(r){return f(u((await r.readFile()).toString()))}var s=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 x(e,"r+");if(!t)throw new Error(`Couldn't find package.json file for path "${e}"!`);let o=await a(t);return await t.close(),new r(o)}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=l(y(j(import.meta.url)),"..","package.json")}async get(e){let t=this.handlers;if(t.has(e))return t.get(e);let o=await s.parse(e);return t.set(e,o),o}async getCurrentPackage(){return this.get(this.currentPJPath)}async getCwd(){return await this.get(l(p,"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 i="never",c="always";var p=process.cwd(),Y=new n;var d=[".mjsx",".jsx"],g=[".mtsx",".tsx"];function H(r){return{apply:{"react-hook-form":k,"react-hooks":J,"react-perf":v,"react-prefer-function-component":F,"react-redux":b},cache:{mapper:{"@eslint-react/debug":"eslint-plugin-react-debug","@eslint-react/dom":"eslint-plugin-react-dom","@eslint-react/hooks-extra":"eslint-plugin-react-hooks-extra","@eslint-react/naming-convention":"eslint-plugin-react-naming-convention","@eslint-react/web-api":"eslint-plugin-react-web-api","@eslint-react/x":"eslint-plugin-react-x"}},extends:["web",P.configs["recommended-typescript"]],languageOptions:{parserOptions:{ecmaFeatures:{jsx:!0}}},name:"react",plugins:{"jsx-a11y":m,"react-refresh":C,style:w,"validate-jsx-nesting":E},rules:[m.flatConfigs.recommended,{"react-refresh/only-export-components":[2,{allowConstantExport:!0,allowExportNames:["meta","links","headers","loader","action","config","generateStaticParams","metadata","generateMetadata","viewport","generateViewport"]}],"style/jsx-child-element-spacing":1,"style/jsx-closing-bracket-location":[1,"line-aligned"],"style/jsx-closing-tag-location":[1,"tag-aligned"],"style/jsx-curly-brace-presence":[1,{children:i,propElementValues:c,props:i}],"style/jsx-curly-newline":1,"style/jsx-curly-spacing":[1,{attributes:{allowMultiline:!1},children:!0,when:i}],"style/jsx-equals-spacing":1,"style/jsx-first-prop-new-line":1,"style/jsx-function-call-newline":1,"style/jsx-newline":[1,{prevent:!0}],"style/jsx-one-expression-per-line":[1,{allow:"single-line"}],"style/jsx-pascal-case":[1,{allowNamespace:!0}],"style/jsx-props-no-multi-spaces":1,"style/jsx-self-closing-comp":[1,{component:!0,html:!0}],"style/jsx-sort-props":[1,{callbacksLast:!0,ignoreCase:!0,locale:"auto",multiline:"last",shorthandFirst:!0}],"style/jsx-tag-spacing":1,"style/jsx-wrap-multilines":1,"validate-jsx-nesting/no-invalid-jsx-nesting":2}],settings:{"import/extensions":[...d,...g],"import/parsers":{"@typescript-eslint/parser":g,espree:d}}}}export{H as default};