@anolilab/lint-staged-config 2.1.7 → 3.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE.md +139 -0
  3. package/README.md +52 -77
  4. package/dist/bin.mjs +88 -0
  5. package/dist/index.cjs +5 -0
  6. package/dist/index.d.cts +41 -0
  7. package/dist/index.d.mts +39 -3
  8. package/dist/index.d.ts +39 -3
  9. package/dist/index.mjs +3 -14
  10. package/package.json +115 -155
  11. package/dist/chunk-24WLFZUE.mjs +0 -8
  12. package/dist/chunk-24WLFZUE.mjs.map +0 -1
  13. package/dist/chunk-ALAT5PPB.js +0 -9
  14. package/dist/chunk-ALAT5PPB.js.map +0 -1
  15. package/dist/chunk-AVDVT4B7.mjs +0 -7
  16. package/dist/chunk-AVDVT4B7.mjs.map +0 -1
  17. package/dist/chunk-COM4XKFJ.mjs +0 -7
  18. package/dist/chunk-COM4XKFJ.mjs.map +0 -1
  19. package/dist/chunk-HGDREIGE.mjs +0 -9
  20. package/dist/chunk-HGDREIGE.mjs.map +0 -1
  21. package/dist/chunk-LJGFRIQ4.mjs +0 -7
  22. package/dist/chunk-LJGFRIQ4.mjs.map +0 -1
  23. package/dist/chunk-OYUEMN5Q.js +0 -9
  24. package/dist/chunk-OYUEMN5Q.js.map +0 -1
  25. package/dist/chunk-P4FK54EG.js +0 -9
  26. package/dist/chunk-P4FK54EG.js.map +0 -1
  27. package/dist/chunk-PLWO6XD7.js +0 -11
  28. package/dist/chunk-PLWO6XD7.js.map +0 -1
  29. package/dist/chunk-VU6SMFTD.js +0 -15
  30. package/dist/chunk-VU6SMFTD.js.map +0 -1
  31. package/dist/groups/eslint/index.d.mts +0 -5
  32. package/dist/groups/eslint/index.d.ts +0 -5
  33. package/dist/groups/eslint/index.js +0 -21
  34. package/dist/groups/eslint/index.js.map +0 -1
  35. package/dist/groups/eslint/index.mjs +0 -19
  36. package/dist/groups/eslint/index.mjs.map +0 -1
  37. package/dist/groups/json.d.mts +0 -5
  38. package/dist/groups/json.d.ts +0 -5
  39. package/dist/groups/json.js +0 -11
  40. package/dist/groups/json.js.map +0 -1
  41. package/dist/groups/json.mjs +0 -9
  42. package/dist/groups/json.mjs.map +0 -1
  43. package/dist/groups/markdown.d.mts +0 -5
  44. package/dist/groups/markdown.d.ts +0 -5
  45. package/dist/groups/markdown.js +0 -12
  46. package/dist/groups/markdown.js.map +0 -1
  47. package/dist/groups/markdown.mjs +0 -10
  48. package/dist/groups/markdown.mjs.map +0 -1
  49. package/dist/groups/secretlint.d.mts +0 -5
  50. package/dist/groups/secretlint.d.ts +0 -5
  51. package/dist/groups/secretlint.js +0 -9
  52. package/dist/groups/secretlint.js.map +0 -1
  53. package/dist/groups/secretlint.mjs +0 -7
  54. package/dist/groups/secretlint.mjs.map +0 -1
  55. package/dist/groups/stylesheets.d.mts +0 -5
  56. package/dist/groups/stylesheets.d.ts +0 -5
  57. package/dist/groups/stylesheets.js +0 -12
  58. package/dist/groups/stylesheets.js.map +0 -1
  59. package/dist/groups/stylesheets.mjs +0 -10
  60. package/dist/groups/stylesheets.mjs.map +0 -1
  61. package/dist/groups/tests.d.mts +0 -5
  62. package/dist/groups/tests.d.ts +0 -5
  63. package/dist/groups/tests.js +0 -11
  64. package/dist/groups/tests.js.map +0 -1
  65. package/dist/groups/tests.mjs +0 -9
  66. package/dist/groups/tests.mjs.map +0 -1
  67. package/dist/groups/typescript.d.mts +0 -5
  68. package/dist/groups/typescript.d.ts +0 -5
  69. package/dist/groups/typescript.js +0 -12
  70. package/dist/groups/typescript.js.map +0 -1
  71. package/dist/groups/typescript.mjs +0 -10
  72. package/dist/groups/typescript.mjs.map +0 -1
  73. package/dist/index.js +0 -19
  74. package/dist/index.js.map +0 -1
  75. package/dist/index.mjs.map +0 -1
  76. package/dist/postinstall.d.mts +0 -2
  77. package/dist/postinstall.d.ts +0 -2
  78. package/dist/postinstall.js +0 -97
  79. package/dist/postinstall.js.map +0 -1
  80. package/dist/postinstall.mjs +0 -95
  81. package/dist/postinstall.mjs.map +0 -1
  82. package/group/package.json +0 -44
  83. package/skip.js +0 -7
package/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ ## @anolilab/lint-staged-config [3.0.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.1.7...@anolilab/lint-staged-config@3.0.0) (2025-05-26)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ * **lint-staged-config:** a new defineConfig func is used to configure, all group exports where removed.
6
+ Signed-off-by: prisis <d.bannert@anolilab.de>
7
+
8
+ ### Features
9
+
10
+ * **lint-staged-config:** added support for nano-staged ([e58cae1](https://github.com/anolilab/javascript-style-guide/commit/e58cae1e8343e068a4112f05dc3fe013bd88b7ae))
11
+ * **lint-staged-config:** create a new defineConfig func to configure lint-staged or nano-staged, with better dx then have the config inside package.json ([8d269ad](https://github.com/anolilab/javascript-style-guide/commit/8d269adfe55de1c0b41a6242b182f395f44735c8))
12
+
13
+ ### Bug Fixes
14
+
15
+ * **lint-staged-config:** updated @visulima/fs and package and all dev deps ([fc53693](https://github.com/anolilab/javascript-style-guide/commit/fc5369341bbc30f2704d864adacdaa56c5ffdcca))
16
+ * refactored post-install to a bin call, fixed wrong namings ([#847](https://github.com/anolilab/javascript-style-guide/issues/847)) ([37ec01e](https://github.com/anolilab/javascript-style-guide/commit/37ec01e583932f92728b494d2fba91e30c8a9f34))
17
+
18
+ ### Miscellaneous Chores
19
+
20
+ * clean update after code changes ([c1ec624](https://github.com/anolilab/javascript-style-guide/commit/c1ec6245a20abfcf1e1d717e148464480f59262c))
21
+ * remove deprecated ESLint and Prettier configurations, update project structure and dependencies ([7b269ed](https://github.com/anolilab/javascript-style-guide/commit/7b269eda93e7dbede5fbdb536dec518dab2bc54b))
22
+ * update lint-staged-config dependencies for compatibility ([b6c656d](https://github.com/anolilab/javascript-style-guide/commit/b6c656d3d22f5cb358468c61c30ccc4bdc22b8ea))
23
+ * update lint-staged-config dependencies to latest versions ([5b4e12f](https://github.com/anolilab/javascript-style-guide/commit/5b4e12f9f162ea30cb7757de55375bf53b9031c3))
24
+ * update node engine compatibility across multiple packages ([8755783](https://github.com/anolilab/javascript-style-guide/commit/8755783d4be3199bd602ede7d83628f83be3f358))
25
+
26
+ ### Continuous Integration
27
+
28
+ * fixed build workflow ([622591f](https://github.com/anolilab/javascript-style-guide/commit/622591f129fea0d30129d45346e49795169accd2))
29
+
1
30
  ## @anolilab/lint-staged-config [2.1.7](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/lint-staged-config@2.1.6...@anolilab/lint-staged-config@2.1.7) (2023-12-22)
2
31
 
3
32
 
package/LICENSE.md CHANGED
@@ -19,3 +19,142 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
+
23
+ <!-- DEPENDENCIES -->
24
+ <!-- /DEPENDENCIES -->
25
+
26
+ <!-- TYPE_DEPENDENCIES -->
27
+
28
+ # Licenses of bundled types
29
+ The published @anolilab/lint-staged-config artifact additionally contains code with the following licenses:
30
+ (MIT OR CC0-1.0)
31
+
32
+ # Bundled types:
33
+ ## type-fest
34
+ License: (MIT OR CC0-1.0)
35
+ By: Sindre Sorhus
36
+ Repository: sindresorhus/type-fest
37
+
38
+ > Creative Commons Legal Code
39
+ >
40
+ > CC0 1.0 Universal
41
+ >
42
+ > CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
43
+ > LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
44
+ > ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
45
+ > INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
46
+ > REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
47
+ > PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
48
+ > THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
49
+ > HEREUNDER.
50
+ >
51
+ > Statement of Purpose
52
+ >
53
+ > The laws of most jurisdictions throughout the world automatically confer
54
+ > exclusive Copyright and Related Rights (defined below) upon the creator
55
+ > and subsequent owner(s) (each and all, an "owner") of an original work of
56
+ > authorship and/or a database (each, a "Work").
57
+ >
58
+ > Certain owners wish to permanently relinquish those rights to a Work for
59
+ > the purpose of contributing to a commons of creative, cultural and
60
+ > scientific works ("Commons") that the public can reliably and without fear
61
+ > of later claims of infringement build upon, modify, incorporate in other
62
+ > works, reuse and redistribute as freely as possible in any form whatsoever
63
+ > and for any purposes, including without limitation commercial purposes.
64
+ > These owners may contribute to the Commons to promote the ideal of a free
65
+ > culture and the further production of creative, cultural and scientific
66
+ > works, or to gain reputation or greater distribution for their Work in
67
+ > part through the use and efforts of others.
68
+ >
69
+ > For these and/or other purposes and motivations, and without any
70
+ > expectation of additional consideration or compensation, the person
71
+ > associating CC0 with a Work (the "Affirmer"), to the extent that he or she
72
+ > is an owner of Copyright and Related Rights in the Work, voluntarily
73
+ > elects to apply CC0 to the Work and publicly distribute the Work under its
74
+ > terms, with knowledge of his or her Copyright and Related Rights in the
75
+ > Work and the meaning and intended legal effect of CC0 on those rights.
76
+ >
77
+ > 1. Copyright and Related Rights. A Work made available under CC0 may be
78
+ > protected by copyright and related or neighboring rights ("Copyright and
79
+ > Related Rights"). Copyright and Related Rights include, but are not
80
+ > limited to, the following:
81
+ >
82
+ > i. the right to reproduce, adapt, distribute, perform, display,
83
+ > communicate, and translate a Work;
84
+ > ii. moral rights retained by the original author(s) and/or performer(s);
85
+ > iii. publicity and privacy rights pertaining to a person's image or
86
+ > likeness depicted in a Work;
87
+ > iv. rights protecting against unfair competition in regards to a Work,
88
+ > subject to the limitations in paragraph 4(a), below;
89
+ > v. rights protecting the extraction, dissemination, use and reuse of data
90
+ > in a Work;
91
+ > vi. database rights (such as those arising under Directive 96/9/EC of the
92
+ > European Parliament and of the Council of 11 March 1996 on the legal
93
+ > protection of databases, and under any national implementation
94
+ > thereof, including any amended or successor version of such
95
+ > directive); and
96
+ > vii. other similar, equivalent or corresponding rights throughout the
97
+ > world based on applicable law or treaty, and any national
98
+ > implementations thereof.
99
+ >
100
+ > 2. Waiver. To the greatest extent permitted by, but not in contravention
101
+ > of, applicable law, Affirmer hereby overtly, fully, permanently,
102
+ > irrevocably and unconditionally waives, abandons, and surrenders all of
103
+ > Affirmer's Copyright and Related Rights and associated claims and causes
104
+ > of action, whether now known or unknown (including existing as well as
105
+ > future claims and causes of action), in the Work (i) in all territories
106
+ > worldwide, (ii) for the maximum duration provided by applicable law or
107
+ > treaty (including future time extensions), (iii) in any current or future
108
+ > medium and for any number of copies, and (iv) for any purpose whatsoever,
109
+ > including without limitation commercial, advertising or promotional
110
+ > purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
111
+ > member of the public at large and to the detriment of Affirmer's heirs and
112
+ > successors, fully intending that such Waiver shall not be subject to
113
+ > revocation, rescission, cancellation, termination, or any other legal or
114
+ > equitable action to disrupt the quiet enjoyment of the Work by the public
115
+ > as contemplated by Affirmer's express Statement of Purpose.
116
+ >
117
+ > 3. Public License Fallback. Should any part of the Waiver for any reason
118
+ > be judged legally invalid or ineffective under applicable law, then the
119
+ > Waiver shall be preserved to the maximum extent permitted taking into
120
+ > account Affirmer's express Statement of Purpose. In addition, to the
121
+ > extent the Waiver is so judged Affirmer hereby grants to each affected
122
+ > person a royalty-free, non transferable, non sublicensable, non exclusive,
123
+ > irrevocable and unconditional license to exercise Affirmer's Copyright and
124
+ > Related Rights in the Work (i) in all territories worldwide, (ii) for the
125
+ > maximum duration provided by applicable law or treaty (including future
126
+ > time extensions), (iii) in any current or future medium and for any number
127
+ > of copies, and (iv) for any purpose whatsoever, including without
128
+ > limitation commercial, advertising or promotional purposes (the
129
+ > "License"). The License shall be deemed effective as of the date CC0 was
130
+ > applied by Affirmer to the Work. Should any part of the License for any
131
+ > reason be judged legally invalid or ineffective under applicable law, such
132
+ > partial invalidity or ineffectiveness shall not invalidate the remainder
133
+ > of the License, and in such case Affirmer hereby affirms that he or she
134
+ > will not (i) exercise any of his or her remaining Copyright and Related
135
+ > Rights in the Work or (ii) assert any associated claims and causes of
136
+ > action with respect to the Work, in either case contrary to Affirmer's
137
+ > express Statement of Purpose.
138
+ >
139
+ > 4. Limitations and Disclaimers.
140
+ >
141
+ > a. No trademark or patent rights held by Affirmer are waived, abandoned,
142
+ > surrendered, licensed or otherwise affected by this document.
143
+ > b. Affirmer offers the Work as-is and makes no representations or
144
+ > warranties of any kind concerning the Work, express, implied,
145
+ > statutory or otherwise, including without limitation warranties of
146
+ > title, merchantability, fitness for a particular purpose, non
147
+ > infringement, or the absence of latent or other defects, accuracy, or
148
+ > the present or absence of errors, whether or not discoverable, all to
149
+ > the greatest extent permissible under applicable law.
150
+ > c. Affirmer disclaims responsibility for clearing rights of other persons
151
+ > that may apply to the Work or any use thereof, including without
152
+ > limitation any person's Copyright and Related Rights in the Work.
153
+ > Further, Affirmer disclaims responsibility for obtaining any necessary
154
+ > consents, permissions or other rights required for any use of the
155
+ > Work.
156
+ > d. Affirmer understands and acknowledges that Creative Commons is not a
157
+ > party to this document and has no duty or obligation with respect to
158
+ > this CC0 or use of the Work.
159
+
160
+ <!-- /TYPE_DEPENDENCIES -->
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <h1>Shareable Lint-Staged Config</h1>
4
4
 
5
- Package that contains shareable configuration for [lint-staged](https://github.com/okonet/lint-staged) — a popular tool for running linters on staged Git files.
5
+ Package that contains shareable configuration for [lint-staged][lint-staged] / [nano-staged][nano-staged] — a popular tool for running linters on staged Git files.
6
6
 
7
7
  And optionally for [husky](https://github.com/typicode/husky) — a popular choice for configuring git hooks.
8
8
 
@@ -24,19 +24,21 @@ And optionally for [husky](https://github.com/typicode/husky) — a popular choi
24
24
 
25
25
  Simplify your project setup with our comprehensive collection of preconfigured configuration files.
26
26
  Designed for effortless integration, these ready-to-use files can be seamlessly imported into your projects.
27
- These functions streamline the utilization of [lint-staged](https://github.com/okonet/lint-staged) alongside popular tools such as [ESLint](https://eslint.org), [Prettier](https://prettier.io), [StyleLint](https://stylelint.io) and [SecretLint](https://github.com/secretlint/secretlint).
27
+ These functions streamline the utilization of [lint-staged][lint-staged] / [nano-staged][nano-staged] alongside popular tools such as [ESLint](https://eslint.org), [Prettier](https://prettier.io), [StyleLint](https://stylelint.io) and [SecretLint](https://github.com/secretlint/secretlint).
28
28
 
29
29
  Say goodbye to complex configurations and enjoy a smoother development experience with our all-inclusive package.
30
30
 
31
31
  ## Purpose
32
32
 
33
- - Enhance your development workflow with hassle-free and readily shareable lint-staged configuration files.
33
+ - Enhance your development workflow with hassle-free and readily shareable lint-staged / nano-staged configuration files.
34
34
  - These files empower developers to maintain a uniform coding style and detect prevalent errors even before they are added to the source control system.
35
35
  - Additionally, our inclusive helper module offers convenient utility functions that seamlessly integrate lint-staged with popular linting and formatting tools.
36
36
 
37
37
  ## Install
38
38
 
39
39
  ```bash
40
+ npm install --dev-save @anolilab/lint-staged-config nano-staged
41
+ // or
40
42
  npm install --dev-save @anolilab/lint-staged-config lint-staged
41
43
 
42
44
  Optional:
@@ -45,6 +47,8 @@ npm install --dev-save husky is-ci
45
47
  ```
46
48
 
47
49
  ```sh
50
+ yarn add -D @anolilab/lint-staged-config nano-staged
51
+ // or
48
52
  yarn add -D @anolilab/lint-staged-config lint-staged
49
53
 
50
54
  Optional:
@@ -53,6 +57,8 @@ yarn add -D husky is-ci
53
57
  ```
54
58
 
55
59
  ```sh
60
+ pnpm add -D @anolilab/lint-staged-config nano-staged
61
+ // or
56
62
  pnpm add -D @anolilab/lint-staged-config lint-staged
57
63
 
58
64
  Optional:
@@ -62,90 +68,43 @@ pnpm add -D husky is-ci
62
68
 
63
69
  ## Usage
64
70
 
65
- If you don’t have a `.lintstagedrc.js`, we will create the file for you after installing `@anolilab/lint-staged-config`.
71
+ If you don’t have a `.lintstagedrc.js` or `.nano-staged.js`, we can create the file for you after installing `@anolilab/lint-staged-config`, call `pnpm lint-stage-config:install`.
66
72
 
67
- If you already have a `.lintstagedrc.js`, then you can extend the `.lintstagedrc.js`, with `@anolilab/lint-staged-config`.
73
+ If you already have a `.lintstagedrc.js` or `.nano-staged.js`, then you can extend the `.lintstagedrc.js` or `.nano-staged.js`, with `@anolilab/lint-staged-config`.
68
74
 
69
- > Note: If the script detects an existing `.lintstagedrc.js` file, it will not overwrite it.
75
+ > Note: If the script detects an existing `.lintstagedrc.js` or `.nano-staged.js` file, it will not overwrite it.
70
76
 
71
- > Note: It can happen that the postinstall script don't run, then you have to add the `.lintstagedrc.js` manually.
72
-
73
- The content of the `.lintstagedrc.js` should look like this:
77
+ The content of the `.lintstagedrc.js` or `.nano-staged.js` should look like this:
74
78
 
75
79
  ```js
76
- const config = require("@anolilab/lint-staged-config");
80
+ const { defineConfig } = require("@anolilab/lint-staged-config");
77
81
 
78
- module.exports = {
79
- ...config,
80
- };
81
- ```
82
- ### Config
82
+ module.exports = defineConfig();
83
83
 
84
- You can configure `@anolilab/lint-staged-config` options with your `package.json` file.
84
+ // or
85
85
 
86
- Add this property to your package.json:
86
+ import { defineConfig } from "@anolilab/lint-staged-config";
87
87
 
88
- ```json5
89
- {
90
- anolilab: {
91
- "lint-staged-config": {
92
- // ...options
93
- },
94
- },
95
- }
88
+ export default defineConfig();
96
89
  ```
90
+ ### Config
97
91
 
98
- #### typescript
92
+ You can configure `@anolilab/lint-staged-config` options inside the `defineConfig` function.
99
93
 
100
- Type: `object`
94
+ ```js
95
+ const { defineConfig } = require("@anolilab/lint-staged-config");
101
96
 
102
- Options:
103
- - `exclude` - Exclude files from tsc linting. Provide the path to the tsconfig.json file.
104
- - Type: `string[]`
105
- - Default: `[]`
97
+ module.exports = defineConfig({
98
+ // Add your configuration here
99
+ });
106
100
 
107
- Example using package.json:
101
+ // or
108
102
 
109
- ```json5
110
- {
111
- "anolilab": {
112
- "lint-staged-config": {
113
- "typescript": {
114
- // ...options
115
- }
116
- }
117
- }
118
- }
119
- ```
103
+ import { defineConfig } from "@anolilab/lint-staged-config";
120
104
 
121
- #### eslint
122
-
123
- Type: `object`
124
-
125
- Options:
126
- - `cache` - Enable or disable caching.
127
- - Type: `boolean`
128
- - config - Change path to eslint config.
129
- - Type: `string`
130
- - "fix-type"
131
- - Type: `string[]`
132
- - "max-warnings"
133
- - Type: `number | string | false`
134
- - rules - Override rules from eslint config.
135
- - Type: `string[]`
136
-
137
- Example using package.json:
138
-
139
- ```json5
140
- {
141
- "anolilab": {
142
- "lint-staged-config": {
143
- "eslint": {
144
- // ...options
145
- }
146
- }
147
- }
148
- }
105
+ export default defineConfig({
106
+ // Add your configuration here
107
+ });
149
108
  ```
150
109
 
151
110
  ## Configuration
@@ -173,8 +132,6 @@ Adding the following script to your root `package.json` file makes it easier to
173
132
  pnpm pkg set scripts.prepare="is-ci || husky install || exit 0"
174
133
  ```
175
134
 
176
- For `npm` users, replace `pnpm` with `npm` in the above command.
177
-
178
135
  This script will install husky only if it is not running in a CI environment.
179
136
 
180
137
  After that you can find a `.husky` folder in your root directory, with a `pre-commit` (if not please create it) file.
@@ -192,16 +149,32 @@ The file content can look like this:
192
149
  echo --------------------------------------------
193
150
  echo Starting Git hook: pre-commit
194
151
 
195
- pnpx lint-staged --verbose --concurrent false
152
+ ./node_modules/.bin/lint-staged --verbose --concurrent false
196
153
 
197
154
  echo Finished Git hook: pre-commit
198
155
  echo --------------------------------------------
199
-
200
156
  ```
201
157
 
202
- Our package includes a `postinstall` script to automatically add the `pre-commit`, `common.sh`, `prepare-commit-msg hooks to your `.husky` folder.
158
+ or with `nano-staged`:
159
+
160
+ ```bash
161
+ #!/bin/sh
162
+
163
+ . "$(dirname "$0")/_/husky.sh"
164
+
165
+ # The hook should exit with non-zero status after issuing
166
+ # an appropriate message if it wants to stop the commit.
167
+
168
+ echo --------------------------------------------
169
+ echo Starting Git hook: pre-commit
170
+
171
+ ./node_modules/.bin/nano-staged
172
+
173
+ echo Finished Git hook: pre-commit
174
+ echo --------------------------------------------
175
+ ```
203
176
 
204
- > Note: It can be that the postinstall script don't run, then you have to add the hooks manually.
177
+ Our package includes a `lint-stage-config:install` command to add the `pre-commit`, `common.sh`, `prepare-commit-msg hooks to your `.husky` folder.
205
178
 
206
179
  If `commitzen` is installed, the `prepare-commit-msg` hook with predefined content will be added to your `.husky` folder.
207
180
 
@@ -235,3 +208,5 @@ The anolilab javascript-style-guide is open-sourced software licensed under the
235
208
  [license-url]: LICENSE.md "license"
236
209
  [npm-image]: https://img.shields.io/npm/v/@anolilab/lint-staged-config/latest.svg?style=for-the-badge&logo=npm
237
210
  [npm-url]: https://www.npmjs.com/package/@anolilab/lint-staged-config/v/latest "npm"
211
+ [lint-staged]: https://github.com/okonet/lint-staged
212
+ [nano-staged]: https://github.com/usmanyunusov/nano-staged
package/dist/bin.mjs ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ var g=Object.defineProperty;var h=(n,o)=>g(n,"name",{value:o,configurable:!0});import{join as s}from"node:path";import{exit as f}from"node:process";import{readFile as u,writeFileSync as r,ensureDirSync as p,isAccessibleSync as $}from"@visulima/fs";import{existsSync as _}from"node:fs";import{parsePackageJson as y,hasPackageJsonAnyDependency as d}from"@visulima/package";var w=Object.defineProperty,l=h((n,o)=>w(n,"name",{value:o,configurable:!0}),"c");const c=l(n=>$(n)?(console.warn(`⚠️ ${n} already exists;`),!0):!1,"checkIfFileExists"),I=l(async(n,o)=>{const e=".lintstagedrc";for(const i of[e,`${e}.js`,`${e}.cjs`,`${e}.mjs`,`${e}.json`,`${e}.yaml`,`${e}.yml`,"lint-staged.config.js","lint-staged.config.mjs","lint-staged.config.cjs"])if(c(s(n,i))){console.warn(`⚠️ ${i} already exists;`);return}const t=s(n,".lintstagedrc.js");r(t,`${o?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
3
+
4
+ ${o?"export default":"module.exports ="} defineConfig();
5
+ `)},"writeLintStagedRc"),x=l(async(n,o)=>{const e=".nano-staged";for(const i of[e,`${e}.js`,`${e}.cjs`,`${e}.mjs`,`${e}.json`,`${e.replace(".","")}.js`,`${e.replace(".","")}.cjs`,`${e.replace(".","")}.mjs`,`${e.replace(".","")}.json`,".nanostagedrc"])if(c(s(n,i))){console.warn(`⚠️ ${i} already exists;`);return}const t=s(n,".nano-staged.js");r(t,`${o?'import { defineConfig } from "@anolilab/lint-staged-config"':'const { defineConfig } = require("@anolilab/lint-staged-config")'};
6
+
7
+ ${o?"export default":"module.exports ="} defineConfig();
8
+ `)},"writeNanoStagedRc"),S=l(async(n,o,e)=>{if(!d(o,["husky"])){console.warn("⚠️ husky is not installed;");return}const t=s(n,".husky");p(t);const i=s(t,"common.sh");c(i)||r(i,`#!/bin/sh
9
+
10
+ command_exists () {
11
+ command -v "$1" >/dev/null 2>&1
12
+ }
13
+
14
+ IS_WINDOWS="false"
15
+
16
+ if [ "$OSTYPE" = "cygwin" ]; then
17
+ IS_WINDOWS="true"
18
+ elif [ "$OSTYPE" = "msys" ]; then
19
+ IS_WINDOWS="true"
20
+ elif [ "$OSTYPE" = "win32" ]; then
21
+ IS_WINDOWS="true"
22
+ fi
23
+
24
+ # Workaround for Windows 10, Git Bash and Yarn
25
+ if [ "$IS_WINDOWS" = "true" ]; then
26
+ if command_exists winpty && test -t 1; then
27
+ exec < /dev/tty
28
+ fi
29
+ fi
30
+ `);const a=s(t,"pre-commit");c(a)||r(a,`#!/bin/sh
31
+
32
+ . "$(dirname "$0")/_/husky.sh"
33
+ . "$(dirname "$0")/common.sh"
34
+
35
+ # The hook should exit with non-zero status after issuing
36
+ # an appropriate message if it wants to stop the commit.
37
+
38
+ echo --------------------------------------------
39
+ echo Starting Git hook: pre-commit
40
+
41
+ ${e?"./node_modules/.bin/nano-staged":"./node_modules/.bin/lint-staged --verbose --concurrent false"}
42
+
43
+ echo Finished Git hook: pre-commit
44
+ echo --------------------------------------------
45
+ `);const m=s(t,"prepare-commit-msg");d(o,["commitizen"])&&!c(m)&&r(m,`#!/bin/sh
46
+
47
+ . "$(dirname "$0")/_/husky.sh"
48
+ . "$(dirname "$0")/common.sh"
49
+
50
+ echo --------------------------------------------
51
+ echo Starting Git hook: prepare-commit-msg
52
+
53
+ # if we hve a cmd that is running ./node_modules/.bin/cz that means finalize and commit
54
+ FILE=commit.cmd
55
+ if test -f "$FILE"; then
56
+ echo "$FILE exists."
57
+ rm commit.cmd
58
+ exit 0;
59
+ fi
60
+ # if on Windows, spawn a cmd that will run ./node_modules/.bin/cz
61
+ case \`uname\` in
62
+ *CYGWIN*|*MINGW*|*MSYS* )
63
+ # Only run commitizen if no commit message was already provided.
64
+ if [ -z "\${2-}" ]; then
65
+ export CZ_TYPE="\${CZ_TYPE:-fix}"
66
+ export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH
67
+ export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH
68
+ echo "./node_modules/.bin/cz && exit" > commit.cmd
69
+ start commit.cmd
70
+ exit 1;
71
+ fi
72
+
73
+ exit 0;;
74
+ esac
75
+
76
+ # Only run commitizen if no commit message was already provided.
77
+ if [ -z "\${2-}" ]; then
78
+ export CZ_TYPE="\${CZ_TYPE:-fix}"
79
+ export CZ_MAX_HEADER_WIDTH=$COMMITLINT_MAX_WIDTH
80
+ export CZ_MAX_LINE_WIDTH=$CZ_MAX_HEADER_WIDTH
81
+ # By default git hooks are not interactive. exec < /dev/tty allows a users terminal to interact with commitizen.
82
+ exec < /dev/tty && ./node_modules/.bin/cz --hook || true
83
+ fi
84
+
85
+ echo Finished Git hook: prepare-commit-msg
86
+ echo --------------------------------------------
87
+ `)},"writeHuskyFiles");(async()=>{const n=process.cwd();console.log("Configuring @anolilab/lint-staged-config",n,`
88
+ `);const o=s(n,"package.json");_(o)||(console.error("No package.json found in the current directory. You need to run this command in a directory with a package.json file."),f(1));const e=y(await u(o)),t=e.type==="module",i=d(e,["lint-staged"]),a=d(e,["nano-staged"]);try{i?await I(n,t):a&&await x(n,t),await S(n,e,a),console.log("Everything went well, have fun!"),f(0)}catch(m){console.error("Something went wrong:",m),f(1)}})();
package/dist/index.cjs ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var D=Object.defineProperty;var f=(s,e)=>D(s,"name",{value:e,configurable:!0});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("@visulima/package"),m=require("@visulima/fs"),J=require("node:fs"),j=require("node:path"),T=require("eslint"),k=require("shell-quote"),w=require("node:process");var q=Object.defineProperty,x=f((s,e)=>q(s,"name",{value:e,configurable:!0}),"o$1");const O=x(s=>{const e=m.findUpSync("package.json",{cwd:s});return e&&j.dirname(e)},"packageDirectorySync"),C=x(s=>{const e=O(s??process.cwd());if(e?.startsWith("/"))return e;throw new Error(`Cannot determine the nearest root of the package for the file: ${s}!`)},"getNearestPackageRootPath"),N=x(s=>{const e=j.join(...s);if(e.startsWith("/"))return e;throw new TypeError("Joined path did not return an absolute path.")},"joinPaths"),v=x((s,e)=>{const i=C(e),t=N([i,s]);if(m.isAccessibleSync(t))return t;throw new Error(`Cannot locate nearest "${s}" file!`)},"getNearestConfigPath");var R=Object.defineProperty,F=f((s,e)=>R(s,"name",{value:e,configurable:!0}),"i$1");const G=F(s=>{const e={};return s.forEach(i=>{const t=j.dirname(i);e[t]||(e[t]=[]),e[t].push(i)}),e},"groupFilePathsByDirectoryName"),P=w.platform==="win32"||/^(msys|cygwin)$/u.test(w.env.OSTYPE??"");var L=Object.defineProperty,M=f((s,e)=>L(s,"name",{value:e,configurable:!0}),"o");const H=M(async s=>{const e=new T.ESLint,i=(await Promise.allSettled(s.map(async t=>await e.isPathIgnored(t)))).map(t=>{if(t.status==="fulfilled")return t.value;throw console.error(`
2
+ Unable to determine if file is ignored.
3
+
4
+
5
+ ${t.reason}`),new Error("Stopping lint-staged because of an error.")});return s.filter((t,n)=>!i[n]).map(t=>`"${P?t:k.quote([t])}"`)},"removeIgnoredFiles");var I=Object.defineProperty,_=f((s,e)=>I(s,"name",{value:e,configurable:!0}),"m");const y=".eslintrc",U=_((s,e)=>{const i=[];s["max-warnings"]!==void 0&&Number.isNaN(s["max-warnings"])?i.push(`--max-warnings=${s["max-warnings"]}`):s["max-warnings"]!==!1&&i.push("--max-warnings=0");const t=[];o.hasPackageJsonAnyDependency(e,["eslint-plugin-react-hooks"])&&t.push("react-hooks/exhaustive-deps:off"),o.hasPackageJsonAnyDependency(e,["eslint-plugin-eslint-comments"])&&t.push("eslint-comments/no-unused-disable:off");const n=[...s.rules??[],...t].filter(p=>p.trim().length>0);n.length>0&&i.push(n.map(p=>`--rule "${p}"`).join(" "));const l=[...s["fix-type"]??["layout"]].filter(p=>p.trim().length>0);return l.length>0&&i.push(`--fix-type ${l.join(",")}`,"--fix"),s.cache&&i.push("--cache"),i},"createEslintArguments"),W=_(async(s,e,i,t)=>{const n=await H(t),l=U(i,e);if(i.config)return l.push(`--config ${i.config}`),[`${s} exec eslint ${l.join(" ")} ${n.join(" ")}`];const p=G(n),d=[];return Object.values(p).forEach(a=>{let r;[y,`${y}.js`,`${y}.cjs`,`${y}.json`,`${y}.yaml`,`${y}.yml`].forEach(g=>{if(!r)try{r=v(g,a[0])}catch{}}),r&&d.push(`${s} exec eslint ${l.join(" ")} --config ${r} ${a.join(" ")}`)}),d},"createEslintCommands");var B=Object.defineProperty,Q=f((s,e)=>B(s,"name",{value:e,configurable:!0}),"r");const c=Q(s=>s.map(e=>`"${P?e:k.quote([e])}"`).join(" ").replaceAll("/@","/@"),"concatFiles");var Y=Object.defineProperty,$=f((s,e)=>Y(s,"name",{value:e,configurable:!0}),"g");const b=["cjs","js","mjs","cts","ts","mts","yml","yaml","jsx","tsx","mdx","toml","json","json5","jsonc"],E=["cts","ts","mts","tsx","ctsx"],A=["css","scss","sass","less","styl","stylus","pcss","postcss","sss"],z=$((s={})=>{const e={debug:!1,eslint:{extensions:b},typescript:{exclude:[],extensions:E},stylesheets:{extensions:A},...s},i=e.cwd||process.cwd();if(!J.existsSync(`${i}/package.json`))throw new Error(`No package.json found in the current working directory: ${i}; Please adjust the "cwd" option.`);const t=o.parsePackageJson(m.readFileSync(`${i}/package.json`)),{packageManager:n}=o.findPackageManagerSync(i);e.debug&&console.debug("Package manager found:",n);const l=o.hasPackageJsonAnyDependency(t,["markdownlint-cli"]),p=o.hasPackageJsonAnyDependency(t,["markdownlint-cli2"]),d=o.hasPackageJsonAnyDependency(t,["prettier"]);let a={};if(e.eslint!==!1&&o.hasPackageJsonAnyDependency(t,["eslint"])){if(!Array.isArray(e.eslint.extensions)||e.eslint.extensions.length===0)throw new Error("The `extensions` option is required for the ESLint configuration.");!l&&!p&&e.eslint.extensions.push("md"),a[`**/*.{${e.eslint.extensions.join(",")}}`]=async r=>[...d?[`${n} exec prettier --write ${c(r)}`]:[],...await W(n,t,e.eslint,r)]}if(e.json!==!1&&o.hasPackageJsonAnyDependency(t,["sort-package-json"])&&(a["**/package.json"]=r=>[`${n} exec sort-package-json ${c(r)}`]),e.markdown!==!1&&l&&(a={...a,"**/*.md":$(r=>[...d?[`${n} exec prettier --write ${c(r)}`]:[],...l?[`${n} exec markdownlint --fix --ignore '**/node_modules/**' --ignore '**/CHANGELOG.md' ${c(r)}`]:[],...p?[`${n} exec markdownlint-cli2 --fix '!**/node_modules/**' '!**/CHANGELOG.md' ${c(r)}`]:[]],"**/*.md"),"**/*.mdx":$(r=>[...d?[`${n} exec prettier --write ${c(r)}`]:[]],"**/*.mdx")}),e.secretlint!==!1&&o.hasPackageJsonAnyDependency(t,["secretlint"])&&(a["**/*"]=r=>[`${n} exec secretlint ${c(r)}`]),e.stylesheets!==!1&&o.hasPackageJsonAnyDependency(t,["stylelint"])){if(!Array.isArray(e.stylesheets.extensions)||e.stylesheets.extensions.length===0)throw new Error("The `extensions` option is required for the Stylesheets configuration.");a[`**/*.{${e.stylesheets.extensions.join(",")}}`]=r=>[...d?[`${n} exec prettier --ignore-unknown --write ${c(r)}`]:[],`${n} exec stylelint --fix`]}if(e.typescript!==!1&&o.hasPackageJsonAnyDependency(t,["typescript"])){if(!Array.isArray(e.typescript.extensions)||e.typescript.extensions.length===0)throw new Error("The `extensions` option is required for the TypeScript configuration.");a[`**/*.{${e.typescript.extensions.join(",")}}`]=r=>{const g=new Set;return r.forEach(h=>{if(typeof e.typescript?.exclude=="object"&&Array.isArray(e.typescript.exclude)){let u=!1;if(e.typescript.exclude.forEach(S=>{!u&&h.includes(S)&&(u=!0)}),u){e.debug&&console.info(`Skipping ${h} as it's excluded in the settings.`);return}}try{const u=v("tsconfig.json",h);g.add(`${n} exec tsc --noEmit --project ${u}`)}catch(u){e.debug&&console.error(u)}}),[...g]}}return o.hasPackageJsonAnyDependency(t,["vitest"])&&(a["**/?(*.){test,spec}.?(c|m)[jt]s?(x)"]=["vitest related --run"],a["**/__tests__/**/*.?(c|m)[jt]s?(x)"]=[`${n} exec vitest related --run`]),o.hasPackageJsonAnyDependency(t,["jest"])&&(a["**/*.spec.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],a["**/*.test.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],a["**/?(*.){test,spec}.?(c|m)[jt]s?(x)"]=[`${n} exec jest --findRelatedTests`],a["**/__mocks__/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],a["**/__tests__/**/*.?(c|m)[jt]s?(x)"]=[`${n} exec jest --findRelatedTests`],a["**/__tests__/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`],a["**/test/*.{js,ts,tsx}"]=[`${n} exec jest --findRelatedTests`]),o.hasPackageJsonAnyDependency(t,["ava"])&&(a["**/(test|tests|__tests__)/**/*.js"]=r=>[`${n} exec ava ${c(r)}`],a["**/*.(spec|test).js"]=r=>[`${n} exec ava ${c(r)}`],a["**/test.js"]=r=>[`${n} exec ava ${c(r)}`],a["**/test-*.js"]=r=>[`${n} exec ava ${c(r)}`]),a},"defineConfig");exports.defineConfig=z;exports.eslintExtensions=b;exports.stylesheetsExtensions=A;exports.typescriptExtensions=E;
@@ -0,0 +1,41 @@
1
+ import * as lintStaged from 'lint-staged';
2
+
3
+ declare global {
4
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5
+ interface SymbolConstructor {
6
+ readonly observable: symbol;
7
+ }
8
+ }
9
+
10
+ type EslintConfig = {
11
+ extensions?: string[];
12
+ cache?: boolean;
13
+ config?: string;
14
+ "fix-type"?: string[];
15
+ "max-warnings"?: number | string | false;
16
+ rules?: string[];
17
+ };
18
+
19
+ type TypescriptConfig = {
20
+ exclude?: string[];
21
+ extensions?: string[];
22
+ };
23
+ type StylesheetsConfig = {
24
+ extensions?: string[];
25
+ };
26
+ declare const eslintExtensions: string[];
27
+ declare const typescriptExtensions: string[];
28
+ declare const stylesheetsExtensions: string[];
29
+ declare const defineConfig: (options?: {
30
+ debug?: boolean;
31
+ cwd?: string;
32
+ eslint?: false | EslintConfig;
33
+ json?: false;
34
+ markdown?: false;
35
+ secretlint?: false;
36
+ stylesheets?: false | StylesheetsConfig;
37
+ tests?: false;
38
+ typescript?: false | TypescriptConfig;
39
+ }) => lintStaged.Configuration;
40
+
41
+ export { defineConfig, eslintExtensions, stylesheetsExtensions, typescriptExtensions };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,41 @@
1
- import { Config } from 'lint-staged';
1
+ import * as lintStaged from 'lint-staged';
2
2
 
3
- declare const loaded: Config;
3
+ declare global {
4
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5
+ interface SymbolConstructor {
6
+ readonly observable: symbol;
7
+ }
8
+ }
4
9
 
5
- export { loaded as default };
10
+ type EslintConfig = {
11
+ extensions?: string[];
12
+ cache?: boolean;
13
+ config?: string;
14
+ "fix-type"?: string[];
15
+ "max-warnings"?: number | string | false;
16
+ rules?: string[];
17
+ };
18
+
19
+ type TypescriptConfig = {
20
+ exclude?: string[];
21
+ extensions?: string[];
22
+ };
23
+ type StylesheetsConfig = {
24
+ extensions?: string[];
25
+ };
26
+ declare const eslintExtensions: string[];
27
+ declare const typescriptExtensions: string[];
28
+ declare const stylesheetsExtensions: string[];
29
+ declare const defineConfig: (options?: {
30
+ debug?: boolean;
31
+ cwd?: string;
32
+ eslint?: false | EslintConfig;
33
+ json?: false;
34
+ markdown?: false;
35
+ secretlint?: false;
36
+ stylesheets?: false | StylesheetsConfig;
37
+ tests?: false;
38
+ typescript?: false | TypescriptConfig;
39
+ }) => lintStaged.Configuration;
40
+
41
+ export { defineConfig, eslintExtensions, stylesheetsExtensions, typescriptExtensions };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,41 @@
1
- import { Config } from 'lint-staged';
1
+ import * as lintStaged from 'lint-staged';
2
2
 
3
- declare const loaded: Config;
3
+ declare global {
4
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
5
+ interface SymbolConstructor {
6
+ readonly observable: symbol;
7
+ }
8
+ }
4
9
 
5
- export { loaded as default };
10
+ type EslintConfig = {
11
+ extensions?: string[];
12
+ cache?: boolean;
13
+ config?: string;
14
+ "fix-type"?: string[];
15
+ "max-warnings"?: number | string | false;
16
+ rules?: string[];
17
+ };
18
+
19
+ type TypescriptConfig = {
20
+ exclude?: string[];
21
+ extensions?: string[];
22
+ };
23
+ type StylesheetsConfig = {
24
+ extensions?: string[];
25
+ };
26
+ declare const eslintExtensions: string[];
27
+ declare const typescriptExtensions: string[];
28
+ declare const stylesheetsExtensions: string[];
29
+ declare const defineConfig: (options?: {
30
+ debug?: boolean;
31
+ cwd?: string;
32
+ eslint?: false | EslintConfig;
33
+ json?: false;
34
+ markdown?: false;
35
+ secretlint?: false;
36
+ stylesheets?: false | StylesheetsConfig;
37
+ tests?: false;
38
+ typescript?: false | TypescriptConfig;
39
+ }) => lintStaged.Configuration;
40
+
41
+ export { defineConfig, eslintExtensions, stylesheetsExtensions, typescriptExtensions };