-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Expand file tree
/
Copy patheslint.medusa.cjs
More file actions
48 lines (44 loc) · 1.85 KB
/
Copy patheslint.medusa.cjs
File metadata and controls
48 lines (44 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Medusa-only ESLint config.
//
// Runs ONLY the `@medusajs/eslint-plugin` convention rules, using the exact
// scope and rules defined in the root `.eslintrc.js` — the root config stays the
// single source of truth, and this config follows it automatically. The style /
// prettier / @typescript-eslint overrides are filtered out so a run reports only
// Medusa rule violations.
//
// Used by the `lint:medusa` npm script (and CI):
// eslint --no-eslintrc --config eslint.medusa.cjs --ignore-path .eslintignore --ext .js,.ts,.tsx .
const root = require("./.eslintrc.js")
// An override that only configures the parser (no `rules`) — kept so TypeScript
// files still parse.
const isRuleless = (o) => !o.rules || Object.keys(o.rules).length === 0
// An override whose every rule is a Medusa rule (`@medusajs/*`).
const isMedusaOverride = (o) =>
o.rules &&
Object.keys(o.rules).length > 0 &&
Object.keys(o.rules).every((rule) => rule.startsWith("@medusajs/"))
const overrides = (root.overrides || []).filter(
(o) => isRuleless(o) || isMedusaOverride(o)
)
module.exports = {
root: true,
// The root config gets JS parser settings from its (dropped) style overrides'
// `extends`; supply modern defaults here so plain `.js`/`.mjs`/`.cjs`/`.jsx`
// files still parse. TypeScript files are handled by the `*.ts`/`*.tsx` parser
// override carried over from the root config.
parserOptions: Object.assign({}, root.parserOptions, {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: Object.assign(
{},
root.parserOptions && root.parserOptions.ecmaFeatures,
{ jsx: true }
),
}),
env: root.env,
// Reuse the same plugin registrations so rule references and any third-party
// `eslint-disable` directives in linted files still resolve (no rules from
// these plugins are enabled here).
plugins: root.plugins,
overrides,
}