eslint-config-shiny
Version:
An eslint config that makes your code so clean and polished that it shines!
2 lines (1 loc) • 4.17 kB
JavaScript
import J from"@eslint-react/eslint-plugin";import P from"@stylistic/eslint-plugin-jsx";import d from"eslint-plugin-jsx-a11y";import j from"eslint-plugin-react-hook-form";import k 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 p,resolve as h}from"node:path";import{fileURLToPath as w}from"node:url";import x from"strip-json-comments";async function a(r){return JSON.parse(x((await r.readFile()).toString()))}import{open as g}from"node:fs/promises";async function i(r,e){try{return await g(r,e)}catch{return}}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 i(e,"r+");if(!t)throw new Error(`Couldn't find package.json file for path "${e}"!`);let n=await a(t);return await t.close(),new r(n)}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=p(y(w(import.meta.url)),"..","package.json")}async get(e){let t=this.handlers;if(t.has(e))return t.get(e);let n=await s.parse(e);return t.set(e,n),n}async getCurrentPackage(){return this.get(this.currentPJPath)}async getCwd(){return await this.get(p(c,"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",m="always";var c=process.cwd(),Y=new o,$=new AbortController;var f=[".mjsx",".jsx"],u=[".mtsx",".tsx"],oe={apply:{"react-hook-form":j,"react-hooks":k,"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",J.configs["recommended-typescript"]],languageOptions:{parserOptions:{ecmaFeatures:{jsx:!0}}},name:"react",plugins:{"jsx-a11y":d,"react-refresh":C,styleJsx:P,"validate-jsx-nesting":E},rules:[d.flatConfigs.recommended,{"react-refresh/only-export-components":[2,{allowConstantExport:!0,allowExportNames:["meta","links","headers","loader","action","config","generateStaticParams","metadata","generateMetadata","viewport","generateViewport"]}],"styleJsx/jsx-child-element-spacing":1,"styleJsx/jsx-closing-bracket-location":[1,"line-aligned"],"styleJsx/jsx-closing-tag-location":[1,"tag-aligned"],"styleJsx/jsx-curly-brace-presence":[1,{children:l,propElementValues:m,props:l}],"styleJsx/jsx-curly-newline":1,"styleJsx/jsx-curly-spacing":[1,{attributes:{allowMultiline:!1},children:!0,when:l}],"styleJsx/jsx-equals-spacing":1,"styleJsx/jsx-first-prop-new-line":1,"styleJsx/jsx-function-call-newline":1,"styleJsx/jsx-newline":[1,{prevent:!0}],"styleJsx/jsx-one-expression-per-line":[1,{allow:"single-line"}],"styleJsx/jsx-pascal-case":[1,{allowNamespace:!0}],"styleJsx/jsx-props-no-multi-spaces":1,"styleJsx/jsx-self-closing-comp":[1,{component:!0,html:!0}],"styleJsx/jsx-sort-props":[1,{callbacksLast:!0,ignoreCase:!0,locale:"auto",multiline:"last",shorthandFirst:!0}],"styleJsx/jsx-tag-spacing":1,"styleJsx/jsx-wrap-multilines":1,"validate-jsx-nesting/no-invalid-jsx-nesting":2}],settings:{"import/extensions":[...f,...u],"import/parsers":{"@typescript-eslint/parser":u,espree:f}}};export{oe as config};