@jimmy.codes/eslint-config 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 @jimmy.codes/eslint-config
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # @jimmy.codes/eslint-config
2
+
3
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/jimmy-guzman/eslint-config/cd.yml?style=flat-square&logo=github-actions)
4
+ [![version](https://img.shields.io/npm/v/@jimmy.codes/eslint-config.svg?logo=npm&style=flat-square)](https://www.npmjs.com/package/@jimmy.codes/eslint-config)
5
+ [![downloads](https://img.shields.io/npm/dm/@jimmy.codes/eslint-config.svg?logo=npm&style=flat-square)](http://www.npmtrends.com/@jimmy.codes/eslint-config)
6
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://semantic-release.gitbook.io/semantic-release)
7
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square&logo=prettier)](https://github.com/prettier/prettier)
8
+
9
+ > 🔍 another opinionated [eslint](https://eslint.org) config
10
+
11
+ _This is an evolution of [eslint-config-jimmy-guzman](https://github.com/jimmy-guzman/eslint-config-jimmy-guzman)_
12
+
13
+ ## 🛠️ Usage
14
+
15
+ ### 🔨 Getting Started
16
+
17
+ First install the package, by running the following:
18
+
19
+ ```
20
+ pnpm add -D @jimmy.codes/eslint-config
21
+ ```
22
+
23
+ Then if you want a simple configuration:
24
+
25
+ ```js
26
+ // eslint.config.mjs
27
+ // @ts-check
28
+ import jimmyDotCodes from "@jimmy.codes/eslint-config";
29
+
30
+ export default jimmyDotCodes();
31
+ ```
32
+
33
+ And if you're using [VS Code](https://code.visualstudio.com), make sure to enable [flat configuration](https://eslint.org/docs/v8.x/use/configure/configuration-files-new):
34
+
35
+ ```jsonc
36
+ // .vscode/settings.json
37
+ {
38
+ "eslint.experimental.useFlatConfig": true,
39
+ }
40
+ ```
41
+
42
+ ### 🔧 Configuration
43
+
44
+ This package contains rules that can be enabled or disabled as follows:
45
+
46
+ ```js
47
+ // eslint.config.mjs
48
+ // @ts-check
49
+ import jimmyDotCodes from "@jimmy.codes/eslint-config";
50
+
51
+ export default jimmyDotCodes({
52
+ /**
53
+ * Are TypeScript rules are enabled?
54
+ * @default false
55
+ */
56
+ typescript: true,
57
+ /**
58
+ * Are React rules are enabled?
59
+ * @default false
60
+ */
61
+ react: true,
62
+ /**
63
+ * Are testing rules are enabled?
64
+ * @default false
65
+ */
66
+ testing: true,
67
+ });
68
+ ```
69
+
70
+ #### TypeScript
71
+
72
+ You can also change the project location which can be helpful for monorepos:
73
+
74
+ ```js
75
+ // eslint.config.mjs
76
+ // @ts-check
77
+ import jimmyDotCodes from "@jimmy.codes/eslint-config";
78
+
79
+ export default jimmyDotCodes({
80
+ typescript: {
81
+ project: ["./tsconfig.eslint.json", "./packages/*/tsconfig.json"],
82
+ },
83
+ });
84
+ ```
85
+
86
+ #### Testing
87
+
88
+ By default [vitest](https://vitest.dev) is used as the testing framework but you can override and add some utilities:
89
+
90
+ ```js
91
+ // eslint.config.mjs
92
+ // @ts-check
93
+ import jimmyDotCodes from "@jimmy.codes/eslint-config";
94
+
95
+ export default jimmyDotCodes({
96
+ testing: {
97
+ framework: "jest",
98
+ utilities: ["testing-library"],
99
+ },
100
+ });
101
+ ```
102
+
103
+ #### Overrides
104
+
105
+ You can also extend or override the configuration:
106
+
107
+ ```js
108
+ // eslint.config.mjs
109
+ // @ts-check
110
+ import jimmyDotCodes from "@jimmy.codes/eslint-config";
111
+
112
+ export default jimmyDotCodes({
113
+ overrides: [
114
+ {
115
+ rules: {
116
+ "prefer-const": "error",
117
+ },
118
+ },
119
+ {
120
+ files: ["/**/*.js"],
121
+ rules: {
122
+ semi: "error",
123
+ },
124
+ },
125
+ ],
126
+ });
127
+ ```
128
+
129
+ ## ❤️ Credits
130
+
131
+ - [@antfu/eslint-config](https://github.com/antfu/eslint-config) by [Anthony Fu](https://antfu.me)
132
+ - [@pvtnbr/eslint-config](https://github.com/privatenumber/eslint-config) by [Hiroki Osame](https://hirok.io/)
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var j=require("eslint-config-prettier"),s=require("eslint-plugin-import-x"),y=require("eslint-plugin-node-import"),g=require("eslint-plugin-simple-import-sort"),i=require("eslint-plugin-jsx-a11y"),x=require("eslint-plugin-react"),h=require("eslint-plugin-react-hooks"),b=require("eslint-plugin-react-refresh"),v=require("globals"),a=require("eslint-plugin-jest"),k=require("eslint-plugin-jest-dom"),p=require("eslint-plugin-testing-library"),c=require("typescript-eslint"),q=require("@eslint/js");function f(e){var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,Object.freeze(r)}var _=f(b),m=f(k);const O={...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"},w={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},C=({typescript:e=!1}={})=>[{name:"jimmy.codes/imports",plugins:{"import-x":s,"simple-import-sort":g,"node-import":y},rules:O},...e?[w]:[]],o="?([cm])[jt]s?(x)",E=["**/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"],L="**/*.?([cm])js",l="**/*.?([cm])jsx",S="**/*.?([cm])tsx",u=[`**/__tests__/**/*.${o}`,`**/*.spec.${o}`,`**/*.test.${o}`,`**/*.bench.${o}`,`**/*.benchmark.${o}`],d=[`**/e2e/**/*.spec.${o}`,`**/e2e/**/*.test.${o}`],G={...i.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","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"},R=()=>[{name:"jimmy.codes/react",files:[l,S],plugins:{react:x,"react-hooks":h,"jsx-a11y":{rules:i.rules},"react-refresh":_},languageOptions:{parserOptions:{jsxPragma:null,ecmaFeatures:{jsx:!0}},globals:{...v.browser}},settings:{react:{version:"detect"}},rules:G}],T={...a.configs["flat/recommended"].rules,...a.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"},B=()=>[{name:"jimmy.codes/testing/testing-library",files:u,plugins:{"testing-library":p,"jest-dom":m},rules:{...p.configs.react.rules,...m.configs["flat/recommended"].rules}},{name:"jimmy.codes/testing/testing-library/disabled",files:d,rules:{"testing-library/prefer-screen-queries":"off"}}],D=({framework:e="vitest",utilities:r})=>[{name:"jimmy.codes/testing",files:u,...a.configs["flat/recommended"],rules:{...T,...e==="vitest"&&{"jest/no-deprecated-functions":"off"}}},{name:"jimmy.codes/testing/disabled",files:d,rules:{"jest/require-hook":"off"}},...r?.includes("testing-library")?B():[]],$=e=>c.config({name:"jimmy.codes/typescript",extends:[...c.configs.strictTypeChecked.map(r=>({name:"jimmy.codes/typescript",...r})),...c.configs.stylisticTypeChecked.map(r=>({name:"jimmy.codes/typescript",...r}))],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}}]}},{name:"jimmy.codes/typescript",languageOptions:{parserOptions:{project:e.project,tsconfigRootDir:process.cwd()}}},{name:"jimmy.codes/typescript",files:[L,l],...c.configs.disableTypeChecked}),I={...q.configs.recommended.rules,curly:"error","arrow-body-style":["error","always"],"object-shorthand":"error","prefer-arrow-callback":"error"},N=e=>typeof e=="object"?e:{project:"./tsconfig.json"},P=e=>typeof e=="object"?e:{framework:"vitest"},X=({typescript:e=!1,react:r=!1,testing:t=!1,overrides:n=[]}={})=>[{name:"jimmy.codes/base",rules:I},...C({typescript:e}),...e?$(N(e)):[],...r?R():[],...t?D(P(t)):[],{name:"jimmy.codes/disabled",...j},{ignores:E},...n];module.exports=X;