@md-code/config 0.0.0-stage → 0.0.2
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/CHANGELOG.md +22 -0
- package/LICENSE +202 -0
- package/README.md +96 -2
- package/eslint/architecture.js +101 -0
- package/eslint/base.js +183 -0
- package/eslint/browser.js +19 -0
- package/eslint/index.js +22 -0
- package/eslint/next.js +14 -0
- package/eslint/node.js +17 -0
- package/eslint/products.js +179 -0
- package/eslint/react-native.js +18 -0
- package/eslint/scope.js +43 -0
- package/package.json +79 -5
- package/stylelint/index.cjs +121 -0
- package/tsconfig/base.json +24 -0
- package/tsconfig/next.json +20 -0
- package/tsconfig/react-native.json +11 -0
- package/tsconfig/react.json +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@md-code/config` are documented here.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.0.2] - 2026-11-29
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- `base`: stops importing `@md-code/follow-architecture/ignore.js`. The list it read
|
|
13
|
+
(`IGNORE_PATHS`) is the scan scope of one repository — md-starter's apps, platform
|
|
14
|
+
packages, tooling scripts and JS files — and spreading it here shipped that scope
|
|
15
|
+
to every consumer. The tool now ships an empty `IGNORE_PATHS` too (0.3.3), and a
|
|
16
|
+
repository states its own scope once: the rule's `ignores` option and the CLI's
|
|
17
|
+
`--ignore` flags.
|
|
18
|
+
|
|
19
|
+
### Removed
|
|
20
|
+
|
|
21
|
+
- The `Known limitation` note about `ignore.js` not being exported: the published
|
|
22
|
+
`@md-code/follow-architecture` does export it, and `base` no longer loads the tool.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @md-code/config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ESLint, TypeScript and Stylelint presets shared by the `@md-code` packages —
|
|
4
|
+
installed from npm instead of being copied.
|
|
5
|
+
|
|
6
|
+
One package, three subpaths:
|
|
7
|
+
|
|
8
|
+
| Subpath | What it is |
|
|
9
|
+
| --------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
10
|
+
| `@md-code/config/eslint` | ESLint flat configs (`base`, `architecture`, `browser`, `next`, `node`, `products`, `reactNative`) |
|
|
11
|
+
| `@md-code/config/tsconfig/*.json` | TypeScript configs (`base`, `react`, `next`, `react-native`) |
|
|
12
|
+
| `@md-code/config/stylelint` | Stylelint config for `styled-components` sources (`postcss-styled-syntax`) |
|
|
13
|
+
|
|
14
|
+
`@md-code/follow-architecture`, `@md-code/utils-uniqueness`,
|
|
15
|
+
`@md-code/entities-uniqueness` and `@md-code/component-uniqueness` are consumed
|
|
16
|
+
from npm (`^0.3.0`) and are not part of this repository. They are **optional
|
|
17
|
+
peers**: this package is the config those tools are linted _with_, so it does not
|
|
18
|
+
depend on them. Installing `@md-code/config` is enough for `tsconfig`, `stylelint` and
|
|
19
|
+
the ESLint configs `base`, `browser`, `node`, `next` and `reactNative`; the
|
|
20
|
+
`architecture` and `products` configs need the tools installed in the project
|
|
21
|
+
that uses them.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pnpm add -D @md-code/config
|
|
27
|
+
|
|
28
|
+
# only for the `architecture` / `products` ESLint configs
|
|
29
|
+
pnpm add -D @md-code/follow-architecture @md-code/utils-uniqueness @md-code/entities-uniqueness @md-code/component-uniqueness
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The repository has no build step — the presets are shipped as-is.
|
|
33
|
+
|
|
34
|
+
## eslint
|
|
35
|
+
|
|
36
|
+
CommonJS:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// eslint.config.cjs
|
|
40
|
+
const { base, architecture, products } = require("@md-code/config/eslint");
|
|
41
|
+
|
|
42
|
+
module.exports = [...base, ...architecture, ...products];
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
ES modules:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
// eslint.config.mjs
|
|
49
|
+
import { base } from "@md-code/config/eslint";
|
|
50
|
+
|
|
51
|
+
export default [...base];
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Names and what each one contains:
|
|
55
|
+
|
|
56
|
+
| Name | Contents |
|
|
57
|
+
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
58
|
+
| `base` | The rules everyone gets: `eslint:recommended` + typescript-eslint `recommended-type-checked` and `stylistic-type-checked` (type-aware, `project: true`), the `anti-trojan-source` and `security` plugins, `import` ordering and type-import rules, the repo-wide `ignores` (build outputs and configs) |
|
|
59
|
+
| `architecture` | The `md-code/follow-architecture` rule, reading `architecture.yaml` from the linted project root. Built lazily: reading it without `@md-code/follow-architecture` installed throws `Cannot load the architecture config: install @md-code/follow-architecture` |
|
|
60
|
+
| `browser` | `base` + `globals.browser` |
|
|
61
|
+
| `node` | `base` + `globals.node` |
|
|
62
|
+
| `next` | `base` + `globals.browser`, for Next.js sources |
|
|
63
|
+
| `reactNative` | `base`, for React Native sources (the RN preset itself is commented out) |
|
|
64
|
+
| `products` | The three `@md-code/*-uniqueness` rules. Exposes `products.configure({ root, utilsFolder, componentsFolder, entitiesRoots })`. Empty (`[]`, and `configure()` returns `[]`) when the three tools are not installed, and always empty when `LINT_PRODUCTS=0` |
|
|
65
|
+
|
|
66
|
+
`architecture` expects an `architecture.yaml` next to the linted project (the
|
|
67
|
+
rule walks up from each file). The tool ships no repository scope; the md-code
|
|
68
|
+
repositories state theirs ONCE in `eslint/scope.js` (`REPOSITORY_IGNORE`: the
|
|
69
|
+
apps, the platform packages, the tooling scripts, every JS file): `base` spreads
|
|
70
|
+
it into the flat `ignores`, the architecture rule gets it as its `ignores`
|
|
71
|
+
option, and a CLI run passes it as `--ignore` flags (md-starter's
|
|
72
|
+
`scripts/fa-ignore.mjs` prints them). Another repository replaces the list there.
|
|
73
|
+
`base` does not load `@md-code/follow-architecture` at all any more.
|
|
74
|
+
|
|
75
|
+
## tsconfig
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
// tsconfig.json
|
|
79
|
+
{ "extends": "@md-code/config/tsconfig/react.json" }
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Available: `base.json`, `react.json`, `next.json`, `react-native.json`.
|
|
83
|
+
|
|
84
|
+
## stylelint
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
// .stylelintrc.json
|
|
88
|
+
{ "extends": "@md-code/config/stylelint" }
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
Apache-2.0. See [LICENSE](./LICENSE).
|
|
94
|
+
|
|
95
|
+
## Repository
|
|
96
|
+
|
|
97
|
+
GitHub: <https://github.com/DrBoria/md-config> · License: Apache-2.0
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// The architecture rule, wired once for every package that extends this config.
|
|
2
|
+
// `packages/styles/README.md` is the styles contract; the repo-root
|
|
3
|
+
// `architecture.yaml` is its enforcement (the STYLES block). The rule scans the
|
|
4
|
+
// repository itself, so it carries its own skip list — ESLint's `ignores` only
|
|
5
|
+
// stops files from being linted, it does not feed a rule option.
|
|
6
|
+
//
|
|
7
|
+
// `@md-code/follow-architecture` is an OPTIONAL peer: this package is the config
|
|
8
|
+
// the tool is linted WITH, so it has to load when the tool is absent. Nothing is
|
|
9
|
+
// required at load time — the tool is resolved on the first access to the
|
|
10
|
+
// exported array, and only that access fails (with a message saying what to
|
|
11
|
+
// install). `require("@md-code/config/eslint")` and destructuring always work.
|
|
12
|
+
|
|
13
|
+
// `architecture.yaml` is named RELATIVE to the project root on purpose. The rule
|
|
14
|
+
// walks up from each linted file to find that file (its `findRepoRoot`), so the
|
|
15
|
+
// same config works here and in any consumer app that installs `@md-code/config` from
|
|
16
|
+
// the registry — there the file lives in `node_modules/@md-code/config/eslint`, and
|
|
17
|
+
// `__dirname` says nothing about where the consumer's architecture.yaml is.
|
|
18
|
+
const ARCH_CONFIG_FILE = "architecture.yaml";
|
|
19
|
+
|
|
20
|
+
const MISSING_TOOL = "Cannot load the architecture config: install @md-code/follow-architecture";
|
|
21
|
+
|
|
22
|
+
// The overview HTML is opt-in: `pnpm lint:overview`. The root script runs the
|
|
23
|
+
// products pass with LINT_OVERVIEW=1, and the flag is part of the turbo task
|
|
24
|
+
// hash, so a cached plain-lint result is never replayed for an overview run.
|
|
25
|
+
const overviewExportPath = () =>
|
|
26
|
+
process.env.LINT_OVERVIEW
|
|
27
|
+
? process.env.LINT_OVERVIEW === "1"
|
|
28
|
+
? "reports/architecture-overview.html"
|
|
29
|
+
: process.env.LINT_OVERVIEW
|
|
30
|
+
: false;
|
|
31
|
+
|
|
32
|
+
const loadTool = () => {
|
|
33
|
+
const firstLine = (message) => String(message).split("\n")[0];
|
|
34
|
+
|
|
35
|
+
let plugin;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
plugin = require("@md-code/follow-architecture");
|
|
39
|
+
} catch (error) {
|
|
40
|
+
throw new Error(`${MISSING_TOOL} (${firstLine(error.message)})`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Scan scope for the architecture rule: the folders the tool never scans. The
|
|
44
|
+
// list is FA's own, so the rule and the CLI look at the same files — a second
|
|
45
|
+
// copy here would be a second scan scope, and a lint run paid for files a scan
|
|
46
|
+
// run skips. The rule ADDS `ignoreDirs` to that list, so this option states the
|
|
47
|
+
// contract instead of restating it.
|
|
48
|
+
try {
|
|
49
|
+
return { plugin, ignore: require("@md-code/follow-architecture/ignore.js") };
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Cannot load the architecture config: @md-code/follow-architecture must expose "ignore.js" (${firstLine(error.message)})`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
let built;
|
|
58
|
+
|
|
59
|
+
const config = () => {
|
|
60
|
+
if (built) return built;
|
|
61
|
+
|
|
62
|
+
const { plugin, ignore } = loadTool();
|
|
63
|
+
|
|
64
|
+
built = [
|
|
65
|
+
{
|
|
66
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
67
|
+
plugins: { "md-code": plugin },
|
|
68
|
+
rules: {
|
|
69
|
+
"md-code/follow-architecture": [
|
|
70
|
+
"error",
|
|
71
|
+
{
|
|
72
|
+
config: ARCH_CONFIG_FILE,
|
|
73
|
+
ignoreDirs: ignore.IGNORE_DIRS,
|
|
74
|
+
// The tool ships no repository scope (`IGNORE_PATHS` is empty since 0.3.3):
|
|
75
|
+
// the apps, the platform packages and the tooling scripts are stated by
|
|
76
|
+
// the repository itself, which adds them here through `ignores`.
|
|
77
|
+
ignores: ignore.IGNORE_PATHS,
|
|
78
|
+
exportPath: overviewExportPath(),
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
return built;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// A Proxy over an empty array, so `Array.isArray()` and a spread keep working
|
|
89
|
+
// while the real config is only built on the first read. Reading anything — even
|
|
90
|
+
// `Symbol.iterator` in `...architecture` — is where a missing tool surfaces.
|
|
91
|
+
module.exports = new Proxy([], {
|
|
92
|
+
get(target, property) {
|
|
93
|
+
const real = config();
|
|
94
|
+
const value = Reflect.get(real, property, real);
|
|
95
|
+
|
|
96
|
+
return typeof value === "function" ? value.bind(real) : value;
|
|
97
|
+
},
|
|
98
|
+
has: (target, property) => Reflect.has(config(), property),
|
|
99
|
+
ownKeys: () => Reflect.ownKeys(config()),
|
|
100
|
+
getOwnPropertyDescriptor: (target, property) => Reflect.getOwnPropertyDescriptor(config(), property),
|
|
101
|
+
});
|
package/eslint/base.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const { FlatCompat } = require("@eslint/eslintrc");
|
|
2
|
+
const js = require("@eslint/js");
|
|
3
|
+
const typescriptEslint = require("@typescript-eslint/eslint-plugin");
|
|
4
|
+
const tsParser = require("@typescript-eslint/parser");
|
|
5
|
+
const _import = require("eslint-plugin-import");
|
|
6
|
+
const pluginSecurity = require("eslint-plugin-security");
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
|
|
9
|
+
// The repository's scan scope, from the one place that states it (`./scope.js`):
|
|
10
|
+
// the apps, the platform packages, the tooling scripts and every JS file. The
|
|
11
|
+
// tool ships none of it (`IGNORE_PATHS` is empty since 0.3.3).
|
|
12
|
+
const { REPOSITORY_IGNORE } = require("./scope.js");
|
|
13
|
+
|
|
14
|
+
// In CommonJS, __dirname is already available, so no need to import fileURLToPath or define __filename
|
|
15
|
+
const compat = new FlatCompat({
|
|
16
|
+
baseDirectory: __dirname,
|
|
17
|
+
recommendedConfig: js.configs.recommended,
|
|
18
|
+
allConfig: js.configs.all,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = [
|
|
22
|
+
{
|
|
23
|
+
// The patterns below are repo-root-relative, so the global ignore resolves
|
|
24
|
+
// them from the root, not from the package whose config required this file
|
|
25
|
+
// (`eslint .` runs with the package as cwd). Three levels above this file is
|
|
26
|
+
// the project root: correct here and as
|
|
27
|
+
// `node_modules/@md-code/config/eslint/base.js` in a consumer.
|
|
28
|
+
basePath: path.resolve(__dirname, "..", "..", ".."),
|
|
29
|
+
// Ignored files and directories
|
|
30
|
+
ignores: [
|
|
31
|
+
"**/hubspot/**/*.js",
|
|
32
|
+
"**/*.config.js",
|
|
33
|
+
"**/*.config.cjs",
|
|
34
|
+
"**/.eslintrc.cjs",
|
|
35
|
+
"**/.next",
|
|
36
|
+
"**/.keystone",
|
|
37
|
+
"**/dist",
|
|
38
|
+
"**/yanm-lock.yaml",
|
|
39
|
+
...REPOSITORY_IGNORE,
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
// Extend recommended configurations
|
|
43
|
+
...compat
|
|
44
|
+
.extends(
|
|
45
|
+
"eslint:recommended",
|
|
46
|
+
"plugin:@typescript-eslint/recommended-type-checked",
|
|
47
|
+
"plugin:anti-trojan-source/recommended",
|
|
48
|
+
"plugin:@typescript-eslint/stylistic-type-checked",
|
|
49
|
+
)
|
|
50
|
+
.map((config) => ({
|
|
51
|
+
...config,
|
|
52
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
53
|
+
})),
|
|
54
|
+
{
|
|
55
|
+
...pluginSecurity.configs.recommended,
|
|
56
|
+
// The repo treats every security rule as an `error` on purpose — a finding
|
|
57
|
+
// here is a defect, not advice. Derived from the plugin's own rule list so
|
|
58
|
+
// a plugin upgrade cannot leave a new rule behind at the default severity.
|
|
59
|
+
rules: Object.fromEntries(Object.keys(pluginSecurity.rules).map((name) => [`security/${name}`, "error"])),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
63
|
+
plugins: {
|
|
64
|
+
"@typescript-eslint": typescriptEslint,
|
|
65
|
+
import: _import,
|
|
66
|
+
},
|
|
67
|
+
linterOptions: {
|
|
68
|
+
reportUnusedDisableDirectives: false,
|
|
69
|
+
noInlineConfig: true,
|
|
70
|
+
},
|
|
71
|
+
languageOptions: {
|
|
72
|
+
parser: tsParser,
|
|
73
|
+
ecmaVersion: 2022,
|
|
74
|
+
sourceType: "module",
|
|
75
|
+
parserOptions: {
|
|
76
|
+
project: true, // Enable type checking via tsconfig
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
rules: {
|
|
80
|
+
"security/detect-object-injection": "off",
|
|
81
|
+
"no-constant-condition": "off",
|
|
82
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
83
|
+
"@typescript-eslint/dot-notation": "off",
|
|
84
|
+
"@typescript-eslint/prefer-nullish-coalescing": "off",
|
|
85
|
+
"@typescript-eslint/no-base-to-string": "off",
|
|
86
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
87
|
+
"@typescript-eslint/array-type": "off",
|
|
88
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
89
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
90
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
|
91
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
92
|
+
"@typescript-eslint/unbound-method": "off",
|
|
93
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "off",
|
|
94
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
95
|
+
"@typescript-eslint/restrict-template-expressions": "off",
|
|
96
|
+
"@typescript-eslint/no-unused-vars": [
|
|
97
|
+
"error",
|
|
98
|
+
{
|
|
99
|
+
argsIgnorePattern: "^_",
|
|
100
|
+
varsIgnorePattern: "^_",
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
"@typescript-eslint/no-misused-promises": [
|
|
104
|
+
"error",
|
|
105
|
+
{
|
|
106
|
+
checksVoidReturn: false,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
110
|
+
"warn",
|
|
111
|
+
{
|
|
112
|
+
prefer: "type-imports",
|
|
113
|
+
fixStyle: "separate-type-imports",
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
117
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
118
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
119
|
+
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
120
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
121
|
+
"@typescript-eslint/ban-ts-comment": [
|
|
122
|
+
"error",
|
|
123
|
+
{
|
|
124
|
+
"ts-expect-error": true,
|
|
125
|
+
"ts-ignore": true,
|
|
126
|
+
"ts-nocheck": true,
|
|
127
|
+
"ts-check": true,
|
|
128
|
+
minimumDescriptionLength: 3,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
"no-restricted-imports": [
|
|
132
|
+
"error",
|
|
133
|
+
{
|
|
134
|
+
patterns: [
|
|
135
|
+
{
|
|
136
|
+
group: ["../*"],
|
|
137
|
+
message:
|
|
138
|
+
"Relative imports from parent directories are forbidden. Please use absolute imports (e.g. @md/...) or sibling imports (./).",
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
"no-restricted-syntax": [
|
|
144
|
+
"error",
|
|
145
|
+
{
|
|
146
|
+
selector:
|
|
147
|
+
"TSAsExpression[typeAnnotation.type='TSTypeReference'][typeAnnotation.typeName.name='unknown'], TSAsExpression[typeAnnotation.type='TSUnknownKeyword']",
|
|
148
|
+
message: "Do not use `as unknown`. It is strictly forbidden.",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
selector:
|
|
152
|
+
"VariableDeclarator[id.name=/^[A-Z][A-Z0-9_]*$/][init.type='Literal'][init.value=/^#([0-9a-fA-F]{3}){1,2}$/]",
|
|
153
|
+
message: "Do not define hex color constants. Use theme variables instead.",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
selector:
|
|
157
|
+
"VariableDeclarator[id.name=/^[A-Z][A-Z0-9_]*$/][init.type='Literal'][init.value=/^-?\\d+(\\.\\d+)?(px|rem|em|vh|vw|%)$/]",
|
|
158
|
+
message: "Do not define CSS unit constants. Use theme variables instead.",
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
"no-warning-comments": [
|
|
162
|
+
"error",
|
|
163
|
+
{
|
|
164
|
+
terms: [
|
|
165
|
+
"eslint-disable",
|
|
166
|
+
"eslint-disable-next-line",
|
|
167
|
+
"eslint-disable-line",
|
|
168
|
+
"eslint-enable",
|
|
169
|
+
"stylelint-disable",
|
|
170
|
+
"stylelint-disable-next-line",
|
|
171
|
+
"stylelint-disable-line",
|
|
172
|
+
"prettier-ignore",
|
|
173
|
+
"ts-ignore",
|
|
174
|
+
"ts-nocheck",
|
|
175
|
+
"ts-check",
|
|
176
|
+
"ts-expect-error",
|
|
177
|
+
],
|
|
178
|
+
location: "anywhere",
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const baseConfig = require("./base.js");
|
|
2
|
+
const globals = require("globals");
|
|
3
|
+
|
|
4
|
+
module.exports = [
|
|
5
|
+
...baseConfig,
|
|
6
|
+
{
|
|
7
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
8
|
+
languageOptions: {
|
|
9
|
+
globals: {
|
|
10
|
+
...globals.browser,
|
|
11
|
+
React: "readonly",
|
|
12
|
+
JSX: "readonly",
|
|
13
|
+
},
|
|
14
|
+
env: {
|
|
15
|
+
browser: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|
package/eslint/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The single entry point for every ESLint flat config this package ships.
|
|
2
|
+
//
|
|
3
|
+
// Consumers destructure what they need — `const { base, products } =
|
|
4
|
+
// require("@md-code/config/eslint")` — so the config file names are never part of the
|
|
5
|
+
// public API. Each value is the module's own array, unchanged: spreading it into
|
|
6
|
+
// a config file behaves exactly like requiring the file did before.
|
|
7
|
+
//
|
|
8
|
+
// A module is loaded on first `require` of this file, so importing `base` also
|
|
9
|
+
// pulls in the architecture rule and the product rules' dependencies. That is a
|
|
10
|
+
// few hundred kilobytes in a devDependency, and it keeps the entry point a plain
|
|
11
|
+
// object instead of a getter dance.
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
base: require("./base.js"),
|
|
16
|
+
architecture: require("./architecture.js"),
|
|
17
|
+
browser: require("./browser.js"),
|
|
18
|
+
next: require("./next.js"),
|
|
19
|
+
node: require("./node.js"),
|
|
20
|
+
products: require("./products.js"),
|
|
21
|
+
reactNative: require("./react-native.js"),
|
|
22
|
+
};
|
package/eslint/next.js
ADDED
package/eslint/node.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const baseConfig = require("./base.js");
|
|
2
|
+
const globals = require("globals");
|
|
3
|
+
|
|
4
|
+
module.exports = [
|
|
5
|
+
...baseConfig,
|
|
6
|
+
{
|
|
7
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
8
|
+
languageOptions: {
|
|
9
|
+
globals: {
|
|
10
|
+
...globals.node,
|
|
11
|
+
},
|
|
12
|
+
env: {
|
|
13
|
+
node: true,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
];
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// The three UNIQUENESS products, wired as ESLint rules for one package.
|
|
2
|
+
//
|
|
3
|
+
// Why these three and not the architecture rule: `follow-architecture` builds a
|
|
4
|
+
// repo-wide ts-morph state per PROCESS, so wiring it here would scan the whole
|
|
5
|
+
// workspace once per package (that is why it lives in
|
|
6
|
+
// `packages/follow-architecture/eslint.products.config.mjs`, run once from the
|
|
7
|
+
// root `lint` / `lint:overview` scripts). The uniqueness rules build their
|
|
8
|
+
// catalogues once per process too, but the catalogue itself is the shared file
|
|
9
|
+
// index, so a warm index makes the per-package cost a stat walk.
|
|
10
|
+
//
|
|
11
|
+
// Imported through the package entry point (`const { products } =
|
|
12
|
+
// require("@md-code/config/eslint")`), so a package config gets it from its
|
|
13
|
+
// devDependency, with no dependency edge inside a workspace.
|
|
14
|
+
//
|
|
15
|
+
// NO `root` IS PASSED. Each rule anchors the repository root on the file it is
|
|
16
|
+
// linting (`options.root || findRepoRoot(dirname(filename)) || findRepoRoot(cwd)`),
|
|
17
|
+
// which is the only value that is right in both worlds: the editor starts the
|
|
18
|
+
// eslint server in a package directory, the CLI may run anywhere, and the same
|
|
19
|
+
// `products.js` is consumed from `node_modules/@md-code/config/eslint/`. Deriving the
|
|
20
|
+
// root from THIS file worked only inside our monorepo: installed as
|
|
21
|
+
// `node_modules/@md-code/config/eslint/products.js` three levels up is the consumer's
|
|
22
|
+
// project root, not ours.
|
|
23
|
+
"use strict";
|
|
24
|
+
|
|
25
|
+
// The editor runs with the rules ON: a package config that spreads this file is
|
|
26
|
+
// what makes `@md-code/*-uniqueness` show up in VS Code out of the box.
|
|
27
|
+
//
|
|
28
|
+
// CI turns them OFF for the per-package phase (`LINT_PRODUCTS=0`, set by the
|
|
29
|
+
// root `lint` script and declared in `turbo.json`): in a fresh process every
|
|
30
|
+
// package would rebuild the catalogue from the 582 MB file index and parse the
|
|
31
|
+
// canon again — measured +30…72 s per package, +3.5 min for `pnpm lint`. The
|
|
32
|
+
// repo-wide products pass (`lint:products`) covers the same rules once, over the
|
|
33
|
+
// whole workspace, and writes the shared `reports/*-catalog.json`/HTML.
|
|
34
|
+
if (process.env.LINT_PRODUCTS === "0") {
|
|
35
|
+
module.exports = [];
|
|
36
|
+
module.exports.configure = () => [];
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const fs = require("node:fs");
|
|
41
|
+
const path = require("node:path");
|
|
42
|
+
|
|
43
|
+
const tsParser = require("@typescript-eslint/parser");
|
|
44
|
+
|
|
45
|
+
// The three uniqueness tools are OPTIONAL peers (see `README.md`): this package is
|
|
46
|
+
// the config those tools are linted WITH, so it loads without them. With any of
|
|
47
|
+
// them missing there is nothing to wire, so `products` is an empty array and
|
|
48
|
+
// `configure()` returns one — a consumer that does not use these rules never has
|
|
49
|
+
// to install the tools.
|
|
50
|
+
const loadTools = () => {
|
|
51
|
+
try {
|
|
52
|
+
return {
|
|
53
|
+
utilsUniqueness: require("@md-code/utils-uniqueness"),
|
|
54
|
+
entitiesUniqueness: require("@md-code/entities-uniqueness"),
|
|
55
|
+
componentUniqueness: require("@md-code/component-uniqueness"),
|
|
56
|
+
};
|
|
57
|
+
} catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const TOOLS = loadTools();
|
|
63
|
+
|
|
64
|
+
// `node_modules/@md-code/config/eslint/products.js` → three levels up is the consumer's
|
|
65
|
+
// project root. Used only to
|
|
66
|
+
// RECOGNISE the monorepo: `packages/utils` next to it exists here and nowhere
|
|
67
|
+
// else, so it tells "our workspace" apart from "installed into somebody's
|
|
68
|
+
// node_modules" without guessing from cwd.
|
|
69
|
+
const PACKAGE_ROOT = path.resolve(__dirname, "..", "..", "..");
|
|
70
|
+
const IN_MONOREPO = fs.existsSync(path.join(PACKAGE_ROOT, "packages", "utils"));
|
|
71
|
+
|
|
72
|
+
// One writer per artifact. The catalogues are repo-wide whatever package is being
|
|
73
|
+
// linted, so every package lint would write the SAME `reports/*-catalog.json` —
|
|
74
|
+
// and turbo runs the packages in parallel. The reports belong to the full-repo
|
|
75
|
+
// products pass; here each package gets a private file it may overwrite at will.
|
|
76
|
+
const packageName = () => {
|
|
77
|
+
const rel = path.relative(PACKAGE_ROOT, process.cwd());
|
|
78
|
+
const outside = rel === "" || rel.startsWith("..") || path.isAbsolute(rel);
|
|
79
|
+
|
|
80
|
+
return outside ? "workspace" : rel.split(path.sep).join("-");
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Fixtures are INPUT to these rules, not product code: a deliberately duplicated
|
|
84
|
+
// sample in `tests/` must never be reported as a finding. Scoped to this fragment
|
|
85
|
+
// (`ignores` next to `files`), so the package's own rules still lint `tests/`.
|
|
86
|
+
// The consumer list is shorter on purpose: it must not silence the consumer's own
|
|
87
|
+
// test suites, and `reports/`/`.turbo/` are ours.
|
|
88
|
+
const MONOREPO = {
|
|
89
|
+
ignores: [
|
|
90
|
+
"**/node_modules/**",
|
|
91
|
+
"**/dist/**",
|
|
92
|
+
"**/build/**",
|
|
93
|
+
"**/out/**",
|
|
94
|
+
"**/coverage/**",
|
|
95
|
+
"**/.turbo/**",
|
|
96
|
+
"**/reports/**",
|
|
97
|
+
"**/tests/**",
|
|
98
|
+
],
|
|
99
|
+
// The scan scope of the products config, verbatim: utils live in
|
|
100
|
+
// `packages/utils`, components in the three UI layers, entities anywhere.
|
|
101
|
+
utilsFolder: ["packages/utils"],
|
|
102
|
+
componentsFolder: ["packages/components/atoms", "packages/components/molecules", "packages/sections"],
|
|
103
|
+
entitiesRoots: ["."],
|
|
104
|
+
// A per-package directory: the shared `reports/` belong to the full-repo pass.
|
|
105
|
+
exportDir: `.turbo/lint/${packageName()}`,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Installed as a dependency there is no `packages/utils` and no `.turbo/lint`:
|
|
109
|
+
// the catalogues go to a cache directory that every consumer ignores by default,
|
|
110
|
+
// and the canon folders are only a starting point — a real consumer names its own
|
|
111
|
+
// through `configure()` below, because no generic guess can be right.
|
|
112
|
+
const CONSUMER = {
|
|
113
|
+
ignores: ["**/node_modules/**", "**/dist/**", "**/build/**", "**/out/**", "**/coverage/**", "**/.next/**"],
|
|
114
|
+
utilsFolder: ["packages/utils"],
|
|
115
|
+
componentsFolder: ["packages/components"],
|
|
116
|
+
entitiesRoots: ["."],
|
|
117
|
+
exportDir: "node_modules/.cache/@md-code/config",
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const DEFAULTS = IN_MONOREPO ? MONOREPO : CONSUMER;
|
|
121
|
+
|
|
122
|
+
// `configure()` is the seam for an outside consumer: everything repo-shaped
|
|
123
|
+
// (folders, where the catalogues go, an explicit `root`) is passed in, and the
|
|
124
|
+
// rest of the wiring — parser, plugin names, severities, one fragment — stays
|
|
125
|
+
// ours. `root` stays optional: the rules find it from the linted file.
|
|
126
|
+
const build = (overrides = {}) => {
|
|
127
|
+
const opts = { ...DEFAULTS, ...overrides };
|
|
128
|
+
const catalog = (name) => (opts.exportDir === false ? null : `${opts.exportDir}/${name}`);
|
|
129
|
+
const ruleOptions = (extra, name) => {
|
|
130
|
+
const options = { ...extra, overviewPath: false };
|
|
131
|
+
|
|
132
|
+
if (opts.root) options.root = opts.root;
|
|
133
|
+
const exportPath = catalog(name);
|
|
134
|
+
|
|
135
|
+
if (exportPath) options.exportPath = exportPath;
|
|
136
|
+
|
|
137
|
+
return ["error", options];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return [
|
|
141
|
+
{
|
|
142
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
143
|
+
ignores: opts.ignores,
|
|
144
|
+
// No type-aware parserOptions on purpose: these rules read the sources
|
|
145
|
+
// themselves, so ESLint only has to PARSE the file in front of it.
|
|
146
|
+
languageOptions: {
|
|
147
|
+
parser: tsParser,
|
|
148
|
+
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
|
|
149
|
+
},
|
|
150
|
+
plugins: {
|
|
151
|
+
"md-code-utils": TOOLS.utilsUniqueness,
|
|
152
|
+
"md-code-entities": TOOLS.entitiesUniqueness,
|
|
153
|
+
"md-code-components": TOOLS.componentUniqueness,
|
|
154
|
+
},
|
|
155
|
+
rules: {
|
|
156
|
+
"md-code-utils/utils-uniqueness": ruleOptions(
|
|
157
|
+
{ ...opts.utilsOptions, utilsFolder: opts.utilsFolder },
|
|
158
|
+
"utils-catalog.json",
|
|
159
|
+
),
|
|
160
|
+
"md-code-entities/entities-uniqueness": ruleOptions(
|
|
161
|
+
{ ...opts.entitiesOptions, roots: opts.entitiesRoots, exclude: [] },
|
|
162
|
+
"entities-catalog.json",
|
|
163
|
+
),
|
|
164
|
+
"md-code-components/component-uniqueness": ruleOptions(
|
|
165
|
+
{ ...opts.componentsOptions, componentsFolder: opts.componentsFolder },
|
|
166
|
+
"component-catalog.json",
|
|
167
|
+
),
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
];
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const products = TOOLS ? build() : [];
|
|
174
|
+
|
|
175
|
+
// `products.configure({ root, utilsFolder, componentsFolder, exportDir, ... })`
|
|
176
|
+
// returns a new flat-config array; the plain array export is the zero-config form.
|
|
177
|
+
products.configure = (overrides) => (TOOLS ? build(overrides) : []);
|
|
178
|
+
|
|
179
|
+
module.exports = products;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const baseConfig = require("./base.js");
|
|
2
|
+
// import { FlatCompat } from "@eslint/eslintrc";
|
|
3
|
+
// import path from "node:path";
|
|
4
|
+
// import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
// const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
// const __dirname = path.dirname(__filename);
|
|
8
|
+
// const compat = new FlatCompat({
|
|
9
|
+
// baseDirectory: __dirname,
|
|
10
|
+
// });
|
|
11
|
+
|
|
12
|
+
module.exports = [
|
|
13
|
+
...baseConfig,
|
|
14
|
+
// ...compat.extends("@react-native-community"),
|
|
15
|
+
{
|
|
16
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
17
|
+
},
|
|
18
|
+
];
|
package/eslint/scope.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// THE SCAN SCOPE OF THE md-starter REPOSITORY, stated once. The tool
|
|
4
|
+
// (`@md-code/follow-architecture`) ships none of it — `IGNORE_PATHS` there is
|
|
5
|
+
// empty — so the two callers that skip files read THIS list: the flat global
|
|
6
|
+
// `ignores` in `base.js` (every lint pass) and the architecture rule's `ignores`
|
|
7
|
+
// option (`packages/follow-architecture/eslint.products.config.mjs`); the CLI
|
|
8
|
+
// run gets the same entries as `--ignore` flags through
|
|
9
|
+
// `scripts/fa-ignore.mjs`. One list, three callers: a second copy would be a
|
|
10
|
+
// second scope, and a lint run and a scan run would quietly disagree.
|
|
11
|
+
//
|
|
12
|
+
// Paths and globs against the repo root: the deployable apps, the platform
|
|
13
|
+
// packages only they consume, the tooling scripts, every JS file (the
|
|
14
|
+
// repository's sources are TypeScript — a `.js`, `.cjs` or `.mjs` here is a
|
|
15
|
+
// config or a build artifact, not contract code), and the generated output and
|
|
16
|
+
// working folders of this repository (`dist`, `coverage`, `.artifacts`, …).
|
|
17
|
+
const REPOSITORY_IGNORE = Object.freeze([
|
|
18
|
+
"apps/**",
|
|
19
|
+
"packages/api/**",
|
|
20
|
+
"packages/native/**",
|
|
21
|
+
"packages/cli/**",
|
|
22
|
+
"packages/infrastructure/**",
|
|
23
|
+
"packages/stylelint/**",
|
|
24
|
+
"scripts/**",
|
|
25
|
+
"**/*.js",
|
|
26
|
+
"**/*.cjs",
|
|
27
|
+
"**/*.mjs",
|
|
28
|
+
"**/dist/**",
|
|
29
|
+
"**/build/**",
|
|
30
|
+
"**/out/**",
|
|
31
|
+
"**/coverage/**",
|
|
32
|
+
"**/.next/**",
|
|
33
|
+
"**/.keystone/**",
|
|
34
|
+
"**/.vscode-test/**",
|
|
35
|
+
".artifacts/**",
|
|
36
|
+
".turbo/**",
|
|
37
|
+
".changeset/**",
|
|
38
|
+
".agent/**",
|
|
39
|
+
"reports/**",
|
|
40
|
+
"screenshots/**",
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
module.exports = { REPOSITORY_IGNORE };
|
package/package.json
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@md-code/config",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Shared ESLint, Stylelint and TypeScript presets, imported by subpath.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"packageManager": "pnpm@10.18.3",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=18"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"eslint/",
|
|
16
|
+
"stylelint/",
|
|
17
|
+
"tsconfig/",
|
|
18
|
+
"CHANGELOG.md"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
"./eslint": "./eslint/index.js",
|
|
22
|
+
"./eslint/*": "./eslint/*.js",
|
|
23
|
+
"./eslint/scope.js": "./eslint/scope.js",
|
|
24
|
+
"./stylelint": "./stylelint/index.cjs",
|
|
25
|
+
"./tsconfig/*.json": "./tsconfig/*.json",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"version-packages": "changeset version",
|
|
30
|
+
"release": "changeset publish"
|
|
31
|
+
},
|
|
32
|
+
"author": "DrBoria <dr.boria@gmail.com>",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/DrBoria/md-config.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/DrBoria/md-config/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/DrBoria/md-config#readme",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
43
|
+
"@eslint/js": "^9.9.1",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
45
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
46
|
+
"eslint": "^9.22.0",
|
|
47
|
+
"eslint-plugin-anti-trojan-source": "^1.1.1",
|
|
48
|
+
"eslint-plugin-import": "^2.29.1",
|
|
49
|
+
"eslint-plugin-security": "^3.0.1",
|
|
50
|
+
"globals": "^15.9.0",
|
|
51
|
+
"postcss-styled-syntax": "^0.6.4",
|
|
52
|
+
"stylelint": "^16.2.0",
|
|
53
|
+
"stylelint-config-standard": "^36.0.0",
|
|
54
|
+
"stylelint-declaration-strict-value": "^1.10.11",
|
|
55
|
+
"stylelint-order": "^6.0.4"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"@md-code/component-uniqueness": "^0.3.0",
|
|
59
|
+
"@md-code/entities-uniqueness": "^0.3.0",
|
|
60
|
+
"@md-code/follow-architecture": "^0.3.0",
|
|
61
|
+
"@md-code/utils-uniqueness": "^0.3.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@md-code/component-uniqueness": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"@md-code/entities-uniqueness": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"@md-code/follow-architecture": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"@md-code/utils-uniqueness": {
|
|
74
|
+
"optional": true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@changesets/cli": "^2.27.0"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ["stylelint-config-standard"],
|
|
3
|
+
customSyntax: "postcss-styled-syntax",
|
|
4
|
+
plugins: ["stylelint-order", "stylelint-declaration-strict-value"],
|
|
5
|
+
rules: {
|
|
6
|
+
"scale-unlimited/declaration-strict-value": [
|
|
7
|
+
[
|
|
8
|
+
"/color/",
|
|
9
|
+
"fill",
|
|
10
|
+
"stroke",
|
|
11
|
+
"/^margin/",
|
|
12
|
+
"/^padding/",
|
|
13
|
+
"gap",
|
|
14
|
+
"/^border/",
|
|
15
|
+
"/^background/",
|
|
16
|
+
"font-size",
|
|
17
|
+
"line-height",
|
|
18
|
+
"letter-spacing",
|
|
19
|
+
"width",
|
|
20
|
+
"height",
|
|
21
|
+
"/^min-/",
|
|
22
|
+
"/^max-/",
|
|
23
|
+
"top",
|
|
24
|
+
"left",
|
|
25
|
+
"right",
|
|
26
|
+
"bottom",
|
|
27
|
+
"box-shadow",
|
|
28
|
+
"text-shadow",
|
|
29
|
+
"z-index",
|
|
30
|
+
"flex-basis",
|
|
31
|
+
"border-radius",
|
|
32
|
+
"opacity",
|
|
33
|
+
],
|
|
34
|
+
{
|
|
35
|
+
ignoreValues: [
|
|
36
|
+
"0",
|
|
37
|
+
"1px",
|
|
38
|
+
"1rem",
|
|
39
|
+
"50%",
|
|
40
|
+
"100%",
|
|
41
|
+
"auto",
|
|
42
|
+
"none",
|
|
43
|
+
"transparent",
|
|
44
|
+
"currentColor",
|
|
45
|
+
"inherit",
|
|
46
|
+
"initial",
|
|
47
|
+
"unset",
|
|
48
|
+
"solid",
|
|
49
|
+
"dashed",
|
|
50
|
+
"dotted",
|
|
51
|
+
"collapse",
|
|
52
|
+
"separate",
|
|
53
|
+
"visible",
|
|
54
|
+
"hidden",
|
|
55
|
+
"scroll",
|
|
56
|
+
"cover",
|
|
57
|
+
"contain",
|
|
58
|
+
"no-repeat",
|
|
59
|
+
"repeat",
|
|
60
|
+
"center",
|
|
61
|
+
"row",
|
|
62
|
+
"column",
|
|
63
|
+
"flex-start",
|
|
64
|
+
"flex-end",
|
|
65
|
+
"baseline",
|
|
66
|
+
"stretch",
|
|
67
|
+
"/^calc\\((?:(?!\\d+(?:px|em|rem|%|vw|vh|vmin|vmax)).)*\\)$/",
|
|
68
|
+
"/fr$/",
|
|
69
|
+
"100vh",
|
|
70
|
+
"100vw",
|
|
71
|
+
"50vh",
|
|
72
|
+
"50vw",
|
|
73
|
+
"/^(?!.*(\\d+(px|em|rem|%|vw|vh)|#|['\"])).*$/",
|
|
74
|
+
"/^-?\\d+(\\.5)?$/",
|
|
75
|
+
"1",
|
|
76
|
+
],
|
|
77
|
+
ignoreVariables: false,
|
|
78
|
+
ignoreFunctions: false,
|
|
79
|
+
expandShorthand: true,
|
|
80
|
+
disableFix: true,
|
|
81
|
+
message: "Use theme variables or allowed exceptions (0, 1px, 100%, ${({ theme }) => theme....ETC})",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
"function-disallowed-list": ["rgb", "rgba", "hsl", "hsla", "hwb", "lab", "lch"],
|
|
85
|
+
"color-no-hex": true,
|
|
86
|
+
"color-named": "never",
|
|
87
|
+
"property-no-unknown": [
|
|
88
|
+
true,
|
|
89
|
+
{
|
|
90
|
+
ignoreProperties: ["/^\\$/"],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
"selector-type-no-unknown": [
|
|
94
|
+
true,
|
|
95
|
+
{
|
|
96
|
+
ignoreTypes: ["/^\\$/"],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
"media-query-no-invalid": null,
|
|
100
|
+
"comment-pattern": [
|
|
101
|
+
"^((?!stylelint-disable)[\\s\\S])*$",
|
|
102
|
+
{
|
|
103
|
+
message: "stylelint-disable comments are not allowed.",
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
overrides: [
|
|
108
|
+
{
|
|
109
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
ignoreFiles: [
|
|
113
|
+
"dist/**/*",
|
|
114
|
+
"coverage/**/*",
|
|
115
|
+
"node_modules/**/*",
|
|
116
|
+
"**/*.d.ts",
|
|
117
|
+
"packages/styles/themes/**/*",
|
|
118
|
+
".next/**/*",
|
|
119
|
+
".turbo/**/*",
|
|
120
|
+
],
|
|
121
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "Default",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"composite": false,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"inlineSources": false,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"module": "commonjs",
|
|
13
|
+
"moduleResolution": "node10",
|
|
14
|
+
"noUnusedLocals": false,
|
|
15
|
+
"noUnusedParameters": false,
|
|
16
|
+
"preserveWatchOutput": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noImplicitAny": true,
|
|
20
|
+
"strictNullChecks": true,
|
|
21
|
+
"resolveJsonModule": true
|
|
22
|
+
},
|
|
23
|
+
"exclude": ["node_modules"]
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "es5",
|
|
6
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"incremental": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"module": "esnext",
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"isolatedModules": true,
|
|
18
|
+
"jsx": "preserve"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"jsx": "react-native",
|
|
6
|
+
"lib": ["dom", "esnext"],
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"module": "esnext",
|
|
9
|
+
"moduleResolution": "bundler"
|
|
10
|
+
}
|
|
11
|
+
}
|