@jimmy.codes/eslint-config 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7507 -305
- package/dist/index.d.mts +7507 -305
- package/dist/index.mjs +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -66,6 +66,14 @@ export default jimmyDotCodes({
|
|
|
66
66
|
});
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
Or you can enable auto detection to enable rules based on a project's dependencies
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
import jimmyDotCodes from "@jimmy.codes/eslint-config";
|
|
73
|
+
|
|
74
|
+
export default jimmyDotCodes({ autoDetect: true });
|
|
75
|
+
```
|
|
76
|
+
|
|
69
77
|
#### TypeScript
|
|
70
78
|
|
|
71
79
|
You can also change the project location which can be helpful for monorepos:
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var x=require("eslint-config-prettier"),l=require("globals"),s=require("eslint-plugin-import-x"),h=require("eslint-plugin-node-import"),b=require("eslint-plugin-simple-import-sort"),v=require("@tanstack/eslint-plugin-query"),m=require("eslint-plugin-jsx-a11y"),k=require("eslint-plugin-react"),q=require("eslint-plugin-react-hooks"),O=require("eslint-plugin-react-refresh"),n=require("eslint-plugin-jest"),_=require("eslint-plugin-jest-dom"),u=require("eslint-plugin-testing-library"),c=require("typescript-eslint"),w=require("@eslint/js");function p(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(o){if(o!=="default"){var a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,a.get?a:{enumerable:!0,get:function(){return e[o]}})}}),t.default=e,Object.freeze(t)}var C=p(v),E=p(O),d=p(_);const L={...s.configs.recommended.rules,"import-x/namespace":"off","import-x/newline-after-import":"error","import-x/first":"error","import-x/no-absolute-path":"error","import-x/no-useless-path-segments":"error","import-x/no-empty-named-blocks":"error","import-x/no-self-import":"error","simple-import-sort/imports":"error","simple-import-sort/exports":"error","node-import/prefer-node-protocol":"error"},S={name:"jimmy.codes/imports/typescript",settings:{...s.configs.typescript.settings,"import-x/resolver":{...s.configs.typescript.settings["import-x/resolver"],typescript:!0}},rules:s.configs.typescript.rules},T=({typescript:e=!1}={})=>[{name:"jimmy.codes/imports",plugins:{"import-x":s,"simple-import-sort":b,"node-import":h},settings:{"import-x/parsers":{espree:[".js",".cjs",".mjs",".jsx"]}},languageOptions:{parserOptions:{ecmaVersion:"latest",sourceType:"module"}},rules:L},...e?[S]:[]],r="?([cm])[jt]s?(x)",G=["**/node_modules","**/dist","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/bun.lockb","**/output","**/coverage","**/temp","**/.temp","**/tmp","**/.tmp","**/.history","**/.vitepress/cache","**/.nuxt","**/.next","**/.vercel","**/.changeset","**/.idea","**/.cache","**/.output","**/.vite-inspect","**/.yarn","**/storybook-static","**/.eslint-config-inspector","**/CHANGELOG*.md","**/*.min.*","**/LICENSE*","**/__snapshots__","**/auto-import?(s).d.ts","**/components.d.ts","**/vite.config.ts.*.mjs"],R="**/*.?([cm])js",f="**/*.?([cm])jsx",j="**/*.?([cm])tsx",i=[`**/__tests__/**/*.${r}`,`**/*.spec.${r}`,`**/*.test.${r}`,`**/*.bench.${r}`,`**/*.benchmark.${r}`],y=[`**/e2e/**/*.spec.${r}`,`**/e2e/**/*.test.${r}`,`**/cypress/**/*.spec.${r}`,`**/cypress/**/*.test.${r}`],$="**/*.cjs",B=["vi.mock"],D={...m.configs.recommended.rules,"react-hooks/exhaustive-deps":"error","react-hooks/rules-of-hooks":"error","react/display-name":"error","react/jsx-key":"error","react/jsx-no-comment-textnodes":"error","react/jsx-no-duplicate-props":"error","react/jsx-no-target-blank":"error","react/jsx-no-undef":"error","react/jsx-uses-vars":"error","react/no-children-prop":"error","react/no-danger-with-children":"error","react/no-deprecated":"error","react/no-direct-mutation-state":"error","react/no-find-dom-node":"error","react/no-is-mounted":"error","react/no-render-return-value":"error","react/no-string-refs":"error","react/no-unescaped-entities":"error","react/no-unknown-property":"error","react/no-unsafe":"off","react/prop-types":"error","react/require-render-return":"error","react/react-in-jsx-scope":"off","react/jsx-uses-react":"off","react-refresh/only-export-components":["warn",{allowConstantExport:!0}],"react/self-closing-comp":"error","react/jsx-curly-brace-presence":"error","react/boolean-prop-naming":"off","react/button-has-type":"error","react/checked-requires-onchange-or-readonly":"error","react/default-props-match-prop-types":"error","react/destructuring-assignment":"off","react/forbid-component-props":"off","react/forbid-dom-props":"off","react/forbid-elements":"off","react/forbid-foreign-prop-types":"off","react/forbid-prop-types":"off","react/function-component-definition":"off","react/hook-use-state":"error","react/iframe-missing-sandbox":"error","react/jsx-boolean-value":["error","never"],"react/jsx-filename-extension":"off","react/jsx-fragments":["error","syntax"],"react/jsx-handler-names":"off","react/jsx-max-depth":"off","react/jsx-no-bind":"off","react/jsx-no-constructed-context-values":"error","react/jsx-no-leaked-render":"error","react/jsx-no-literals":"off","react/jsx-no-script-url":"error","react/jsx-no-useless-fragment":"error","react/jsx-one-expression-per-line":"off","react/jsx-pascal-case":["error",{allowNamespace:!0}],"react/jsx-props-no-spreading":"off","react/jsx-sort-default-props":"off","react/jsx-sort-props":"off","react/no-access-state-in-setstate":"error","react/no-adjacent-inline-elements":"off","react/no-array-index-key":"off","react/no-arrow-function-lifecycle":"error","react/no-danger":"off","react/no-did-mount-set-state":"error","react/no-did-update-set-state":"error","react/no-invalid-html-attribute":"error","react/no-multi-comp":"off","react/no-namespace":"error","react/no-object-type-as-default-prop":"off","react/no-redundant-should-component-update":"error","react/no-set-state":"off","react/no-this-in-sfc":"error","react/no-typos":"error","react/no-unstable-nested-components":"error","react/no-unused-class-component-methods":"error","react/no-unused-prop-types":"error","react/no-unused-state":"error","react/no-will-update-set-state":"error","react/prefer-es6-class":"off","react/prefer-exact-props":"off","react/prefer-read-only-props":"off","react/prefer-stateless-function":"off","react/require-default-props":"off","react/require-optimization":"off","react/sort-comp":"off","react/sort-default-props":"off","react/sort-prop-types":"off","react/state-in-constructor":"off","react/static-property-placement":"off","react/style-prop-object":"error","react/void-dom-elements-no-children":"error"},I=({utilities:e=[]}={})=>[{name:"jimmy.codes/react",files:[f,j],plugins:{react:k,"react-hooks":q,"jsx-a11y":{rules:m.rules},"react-refresh":E},languageOptions:{parserOptions:{jsxPragma:null,ecmaFeatures:{jsx:!0}},globals:{...l.browser}},settings:{react:{version:"detect"}},rules:D},...e.includes("@tanstack/query")?[{name:"jimmy.codes/react/query",files:[f,j],plugins:{"@tanstack/query":C},rules:{"@tanstack/query/exhaustive-deps":"error","@tanstack/query/no-rest-destructuring":"warn","@tanstack/query/stable-query-client":"error"}}]:[]],g={...n.configs["flat/recommended"].rules,...n.configs["flat/style"].rules,"jest/no-alias-methods":"error","jest/no-commented-out-tests":"error","jest/consistent-test-it":["error",{fn:"test",withinDescribe:"it"}],"jest/no-conditional-in-test":"error","jest/no-confusing-set-timeout":"error","jest/no-duplicate-hooks":"error","jest/no-hooks":"off","jest/no-large-snapshots":"off","jest/no-restricted-jest-methods":"off","jest/no-restricted-matchers":"off","jest/no-test-return-statement":"error","jest/no-untyped-mock-factory":"off","jest/prefer-called-with":"error","jest/prefer-comparison-matcher":"error","jest/prefer-each":"error","jest/prefer-equality-matcher":"error","jest/prefer-expect-assertions":"off","jest/prefer-expect-resolves":"error","jest/prefer-hooks-in-order":"error","jest/prefer-hooks-on-top":"error","jest/prefer-lowercase-title":"off","jest/prefer-mock-promise-shorthand":"error","jest/prefer-snapshot-hint":"error","jest/prefer-spy-on":"off","jest/prefer-strict-equal":"error","jest/prefer-todo":"warn","jest/require-hook":"error","jest/require-to-throw-message":"error","jest/require-top-level-describe":"off","jest/unbound-method":"off"},N=()=>[{name:"jimmy.codes/testing/testing-library",files:i,plugins:{"testing-library":u,"jest-dom":d},rules:{...u.configs.react.rules,...d.configs["flat/recommended"].rules}},{name:"jimmy.codes/testing/testing-library/disabled",files:y,rules:{"testing-library/prefer-screen-queries":"off"}}],P=({framework:e="vitest",utilities:t}={})=>[{name:"jimmy.codes/testing",files:i,...n.configs["flat/recommended"]},...e==="vitest"?[{name:"jimmy.codes/testing/vitest",files:i,...n.configs["flat/recommended"],rules:{...g,"jest/no-deprecated-functions":"off","jest/require-hook":["error",{allowedFunctionCalls:B}]}}]:[{name:"jimmy.codes/testing/jest",files:i,...n.configs["flat/recommended"],rules:g}],{name:"jimmy.codes/testing/disabled",files:y,rules:{"jest/expect-expect":"off","jest/no-deprecated-functions":"off","jest/require-hook":"off"}},...t?.includes("testing-library")?N():[]],X=e=>c.config(...c.configs.strictTypeChecked,{name:"jimmy.codes/typescript",extends:[...c.configs.strictTypeChecked,...c.configs.stylisticTypeChecked],languageOptions:{parserOptions:{project:e.project,tsconfigRootDir:process.cwd()}},rules:{"@typescript-eslint/consistent-type-imports":["error",{fixStyle:"inline-type-imports"}],"@typescript-eslint/consistent-type-exports":["error",{fixMixedExportsWithInlineTypeSpecifier:!0}],"@typescript-eslint/no-misused-promises":["error",{checksVoidReturn:{attributes:!1}}],"@typescript-eslint/restrict-template-expressions":["error",{allowNumber:!0}]}},{files:[R,f],...c.configs.disableTypeChecked}),A={...w.configs.recommended.rules,curly:"error","arrow-body-style":["error","always"],"object-shorthand":"error","prefer-arrow-callback":"error","no-console":"warn"},F=e=>typeof e=="object"?e:{project:"./tsconfig.json"},J=e=>typeof e=="object"?e:{framework:"vitest"},V=e=>typeof e=="object"?e:{utilities:[]},z=({typescript:e=!1,react:t=!1,testing:o=!1,overrides:a=[]}={})=>[{name:"jimmy.codes/base",rules:A},...T({typescript:e}),...e?X(F(e)):[],...t?I(V(t)):[],...o?P(J(o)):[],{name:"jimmy.codes/disabled",...x},{name:"jimmy.codes/commonjs",files:[$],languageOptions:{globals:l.commonjs}},{ignores:G},...a];module.exports=z;
|
|
1
|
+
"use strict";var O=require("eslint-config-prettier"),d=require("globals"),a=require("eslint-plugin-import-x"),E=require("eslint-plugin-node-import"),w=require("eslint-plugin-simple-import-sort"),T=require("@tanstack/eslint-plugin-query"),j=require("eslint-plugin-jsx-a11y"),C=require("eslint-plugin-react"),L=require("eslint-plugin-react-hooks"),R=require("eslint-plugin-react-refresh"),c=require("local-pkg"),i=require("eslint-plugin-jest"),S=require("eslint-plugin-jest-dom"),y=require("eslint-plugin-testing-library"),p=require("typescript-eslint"),G=require("@eslint/js");function m(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var P=m(T),I=m(R),g=m(S);const s="?([cm])[jt]s?(x)",B=["**/node_modules","**/dist","**/package-lock.json","**/yarn.lock","**/pnpm-lock.yaml","**/bun.lockb","**/output","**/coverage","**/temp","**/.temp","**/tmp","**/.tmp","**/.history","**/.vitepress/cache","**/.nuxt","**/.next","**/.vercel","**/.changeset","**/.idea","**/.cache","**/.output","**/.vite-inspect","**/.yarn","**/storybook-static","**/.eslint-config-inspector","**/CHANGELOG*.md","**/*.min.*","**/LICENSE*","**/__snapshots__","**/auto-import?(s).d.ts","**/components.d.ts","**/vite.config.ts.*.mjs"],$="**/*.?([cm])js",u="**/*.?([cm])jsx",x="**/*.?([cm])tsx",l=[`**/__tests__/**/*.${s}`,`**/*.spec.${s}`,`**/*.test.${s}`,`**/*.bench.${s}`,`**/*.benchmark.${s}`],h=[`**/e2e/**/*.spec.${s}`,`**/e2e/**/*.test.${s}`,`**/cypress/**/*.spec.${s}`,`**/cypress/**/*.test.${s}`],N="**/*.cjs",A=["vi.mock"],J=["@testing-library/react"],V=()=>[{name:"jimmy.codes/commonjs",files:[N],languageOptions:{globals:d.commonjs}}],F={...a.configs.recommended.rules,"import-x/namespace":"off","import-x/newline-after-import":"error","import-x/first":"error","import-x/no-absolute-path":"error","import-x/no-useless-path-segments":"error","import-x/no-empty-named-blocks":"error","import-x/no-self-import":"error","simple-import-sort/imports":"error","simple-import-sort/exports":"error","node-import/prefer-node-protocol":"error"},Q={name:"jimmy.codes/imports/typescript",settings:{...a.configs.typescript.settings,"import-x/resolver":{...a.configs.typescript.settings["import-x/resolver"],typescript:!0}},rules:a.configs.typescript.rules},X=({typescript:e=!1}={})=>[{name:"jimmy.codes/imports",plugins:{"import-x":a,"simple-import-sort":w,"node-import":E},settings:{"import-x/parsers":{espree:[".js",".cjs",".mjs",".jsx"]}},languageOptions:{parserOptions:{ecmaVersion:"latest",sourceType:"module"}},rules:F},...e?[Q]:[]],z=()=>c.isPackageExists("typescript"),D=()=>c.isPackageExists("react"),b=()=>c.isPackageExists("vitest"),k=()=>c.isPackageExists("jest"),H=()=>b()||k(),M=()=>J.some(e=>c.isPackageExists(e)),W=()=>c.isPackageExists("@tanstack/react-query"),Y={...j.configs.recommended.rules,"react-hooks/exhaustive-deps":"error","react-hooks/rules-of-hooks":"error","react/display-name":"error","react/jsx-key":"error","react/jsx-no-comment-textnodes":"error","react/jsx-no-duplicate-props":"error","react/jsx-no-target-blank":"error","react/jsx-no-undef":"error","react/jsx-uses-vars":"error","react/no-children-prop":"error","react/no-danger-with-children":"error","react/no-deprecated":"error","react/no-direct-mutation-state":"error","react/no-find-dom-node":"error","react/no-is-mounted":"error","react/no-render-return-value":"error","react/no-string-refs":"error","react/no-unescaped-entities":"error","react/no-unknown-property":"error","react/no-unsafe":"off","react/prop-types":"error","react/require-render-return":"error","react/react-in-jsx-scope":"off","react/jsx-uses-react":"off","react-refresh/only-export-components":["warn",{allowConstantExport:!0}],"react/self-closing-comp":"error","react/jsx-curly-brace-presence":"error","react/boolean-prop-naming":"off","react/button-has-type":"error","react/checked-requires-onchange-or-readonly":"error","react/default-props-match-prop-types":"error","react/destructuring-assignment":"off","react/forbid-component-props":"off","react/forbid-dom-props":"off","react/forbid-elements":"off","react/forbid-foreign-prop-types":"off","react/forbid-prop-types":"off","react/function-component-definition":"off","react/hook-use-state":"error","react/iframe-missing-sandbox":"error","react/jsx-boolean-value":["error","never"],"react/jsx-filename-extension":"off","react/jsx-fragments":["error","syntax"],"react/jsx-handler-names":"off","react/jsx-max-depth":"off","react/jsx-no-bind":"off","react/jsx-no-constructed-context-values":"error","react/jsx-no-leaked-render":"error","react/jsx-no-literals":"off","react/jsx-no-script-url":"error","react/jsx-no-useless-fragment":"error","react/jsx-one-expression-per-line":"off","react/jsx-pascal-case":["error",{allowNamespace:!0}],"react/jsx-props-no-spreading":"off","react/jsx-sort-default-props":"off","react/jsx-sort-props":"off","react/no-access-state-in-setstate":"error","react/no-adjacent-inline-elements":"off","react/no-array-index-key":"off","react/no-arrow-function-lifecycle":"error","react/no-danger":"off","react/no-did-mount-set-state":"error","react/no-did-update-set-state":"error","react/no-invalid-html-attribute":"error","react/no-multi-comp":"off","react/no-namespace":"error","react/no-object-type-as-default-prop":"off","react/no-redundant-should-component-update":"error","react/no-set-state":"off","react/no-this-in-sfc":"error","react/no-typos":"error","react/no-unstable-nested-components":"error","react/no-unused-class-component-methods":"error","react/no-unused-prop-types":"error","react/no-unused-state":"error","react/no-will-update-set-state":"error","react/prefer-es6-class":"off","react/prefer-exact-props":"off","react/prefer-read-only-props":"off","react/prefer-stateless-function":"off","react/require-default-props":"off","react/require-optimization":"off","react/sort-comp":"off","react/sort-default-props":"off","react/sort-prop-types":"off","react/state-in-constructor":"off","react/static-property-placement":"off","react/style-prop-object":"error","react/void-dom-elements-no-children":"error"},U=({utilities:e=[]}={},t=!1)=>{const r=e.includes("@tanstack/query")||t&&W();return[{name:"jimmy.codes/react",files:[u,x],plugins:{react:C,"react-hooks":L,"jsx-a11y":{rules:j.rules},"react-refresh":I},languageOptions:{parserOptions:{jsxPragma:null,ecmaFeatures:{jsx:!0}},globals:{...d.browser}},settings:{react:{version:"detect"}},rules:Y},...r?[{name:"jimmy.codes/react/query",files:[u,x],plugins:{"@tanstack/query":P},rules:{"@tanstack/query/exhaustive-deps":"error","@tanstack/query/no-rest-destructuring":"warn","@tanstack/query/stable-query-client":"error"}}]:[]]},v={...i.configs["flat/recommended"].rules,...i.configs["flat/style"].rules,"jest/no-alias-methods":"error","jest/no-commented-out-tests":"error","jest/consistent-test-it":["error",{fn:"test",withinDescribe:"it"}],"jest/no-conditional-in-test":"error","jest/no-confusing-set-timeout":"error","jest/no-duplicate-hooks":"error","jest/no-hooks":"off","jest/no-large-snapshots":"off","jest/no-restricted-jest-methods":"off","jest/no-restricted-matchers":"off","jest/no-test-return-statement":"error","jest/no-untyped-mock-factory":"off","jest/prefer-called-with":"error","jest/prefer-comparison-matcher":"error","jest/prefer-each":"error","jest/prefer-equality-matcher":"error","jest/prefer-expect-assertions":"off","jest/prefer-expect-resolves":"error","jest/prefer-hooks-in-order":"error","jest/prefer-hooks-on-top":"error","jest/prefer-lowercase-title":"off","jest/prefer-mock-promise-shorthand":"error","jest/prefer-snapshot-hint":"error","jest/prefer-spy-on":"off","jest/prefer-strict-equal":"error","jest/prefer-todo":"warn","jest/require-hook":"error","jest/require-to-throw-message":"error","jest/require-top-level-describe":"off","jest/unbound-method":"off"},K=()=>[{name:"jimmy.codes/testing/testing-library",files:l,plugins:{"testing-library":y,"jest-dom":g},rules:{...y.configs.react.rules,...g.configs["flat/recommended"].rules}},{name:"jimmy.codes/testing/testing-library/disabled",files:h,rules:{"testing-library/prefer-screen-queries":"off"}}],Z=({framework:e="vitest",utilities:t}={},r=!1)=>{const n=r?b():e==="vitest",o=e==="jest"||r&&k(),f=!!t?.includes("testing-library")||r&&M();return[{name:"jimmy.codes/testing",files:l,...i.configs["flat/recommended"]},...n?[{name:"jimmy.codes/testing/vitest",files:l,...i.configs["flat/recommended"],rules:{...v,"jest/no-deprecated-functions":"off","jest/require-hook":["error",{allowedFunctionCalls:A}]}}]:[],...o?[{name:"jimmy.codes/testing/jest",files:l,...i.configs["flat/recommended"],rules:v}]:[],{name:"jimmy.codes/testing/disabled",files:h,rules:{"jest/expect-expect":"off","jest/no-deprecated-functions":"off","jest/require-hook":"off"}},...f?K():[]]},ee=e=>p.config(...p.configs.strictTypeChecked,{name:"jimmy.codes/typescript",extends:[...p.configs.strictTypeChecked,...p.configs.stylisticTypeChecked],languageOptions:{parserOptions:{project:e.project,tsconfigRootDir:process.cwd()}},rules:{"@typescript-eslint/consistent-type-imports":["error",{fixStyle:"inline-type-imports"}],"@typescript-eslint/consistent-type-exports":["error",{fixMixedExportsWithInlineTypeSpecifier:!0}],"@typescript-eslint/no-misused-promises":["error",{checksVoidReturn:{attributes:!1}}],"@typescript-eslint/restrict-template-expressions":["error",{allowNumber:!0}]}},{files:[$,u],...p.configs.disableTypeChecked}),re={...G.configs.recommended.rules,curly:["error","multi-or-nest","consistent"],"arrow-body-style":["error","always"],"object-shorthand":"error","no-useless-rename":"error","prefer-arrow-callback":"error","no-console":"warn"},te=e=>typeof e=="object"?e:{project:"./tsconfig.json"},se=e=>typeof e=="object"?e:{framework:"vitest"},oe=e=>typeof e=="object"?e:{utilities:[]},ne=({typescript:e=!1,react:t=!1,testing:r=!1,overrides:n=[],autoDetect:o=!1}={})=>{const f=e||o&&z(),q=t||o&&D(),_=r||o&&H();return[{name:"jimmy.codes/base",rules:re},...X({typescript:f}),...f?ee(te(e)):[],...q?U(oe(t),o):[],..._?Z(se(r),o):[],{name:"jimmy.codes/disabled",...O},...V(),{ignores:B},...n]};module.exports=ne;
|