Raw
1 import prettier from "eslint-plugin-prettier"
2 import markdown from "eslint-plugin-markdown"
3 import medusaContentConfigs from "../../content-lint-medusa.mjs"
4 import titledMarkdownProcessor from "../../content-lint-processor.mjs"
5 import globals from "globals"
6 import babelParser from "@babel/eslint-parser"
7 import typescriptEslintEslintPlugin from "@typescript-eslint/eslint-plugin"
8 import tsParser from "@typescript-eslint/parser"
9 import path from "node:path"
10 import { fileURLToPath } from "node:url"
11 import js from "@eslint/js"
12 import { FlatCompat } from "@eslint/eslintrc"
13
14 const __filename = fileURLToPath(import.meta.url)
15 const __dirname = path.dirname(__filename)
16 const compat = new FlatCompat({
17 baseDirectory: __dirname,
18 recommendedConfig: js.configs.recommended,
19 allConfig: js.configs.all,
20 })
21
22 export default [
23 {
24 ignores: [
25 "**/references/**/*",
26 // TODO remove this once we support v1 comments
27 "**/nextjs-starter/guides/customize-stripe/**",
28 "**/lint/**",
29 ],
30 },
31 {
32 plugins: {
33 prettier,
34 markdown,
35 },
36
37 languageOptions: {
38 globals: {
39 ...globals.node,
40 },
41
42 parser: babelParser,
43 ecmaVersion: 13,
44 sourceType: "module",
45
46 parserOptions: {
47 requireConfigFile: false,
48
49 ecmaFeatures: {
50 experimentalDecorators: true,
51 modules: true,
52 },
53 },
54 },
55
56 settings: {
57 react: {
58 version: "detect",
59 },
60 },
61
62 rules: {
63 "no-undef": "off",
64 "no-unused-expressions": "off",
65 "no-unused-vars": "off",
66 "no-unused-labels": "off",
67 "no-console": "off",
68 curly: ["error", "all"],
69 "new-cap": "off",
70 "require-jsdoc": "off",
71 camelcase: "off",
72 "no-invalid-this": "off",
73
74 "max-len": [
75 "warn",
76 {
77 code: 64,
78 },
79 ],
80
81 semi: ["error", "never"],
82
83 quotes: [
84 "error",
85 "double",
86 {
87 allowTemplateLiterals: true,
88 },
89 ],
90
91 "comma-dangle": [
92 "error",
93 {
94 arrays: "always-multiline",
95 objects: "always-multiline",
96 imports: "always-multiline",
97 exports: "always-multiline",
98 functions: "never",
99 },
100 ],
101
102 "object-curly-spacing": ["error", "always"],
103 "arrow-parens": ["error", "always"],
104 "linebreak-style": 0,
105
106 "no-confusing-arrow": [
107 "error",
108 {
109 allowParens: false,
110 },
111 ],
112
113 "space-before-function-paren": [
114 "error",
115 {
116 anonymous: "always",
117 named: "never",
118 asyncArrow: "always",
119 },
120 ],
121
122 "space-infix-ops": "off",
123 "eol-last": ["error", "always"],
124 "react/prop-types": "off",
125 "react/jsx-no-undef": "off",
126 },
127 },
128 {
129 files: ["**/*.md", "**/*.mdx"],
130 processor: titledMarkdownProcessor,
131 },
132 {
133 files: [
134 "**/*.md/**/*.js",
135 "**/*.mdx/**/*.js",
136 "**/*.md/**/*.jsx",
137 "**/*.mdx/**/*.jsx",
138 ],
139 },
140 ...compat.extends("plugin:@typescript-eslint/recommended").map((config) => ({
141 ...config,
142 files: [
143 "**/*.md/**/*.ts",
144 "**/*.mdx/**/*.ts",
145 "**/*.md/**/*.tsx",
146 "**/*.mdx/**/*.tsx",
147 ],
148 })),
149 {
150 files: [
151 "**/*.md/**/*.ts",
152 "**/*.mdx/**/*.ts",
153 "**/*.md/**/*.tsx",
154 "**/*.mdx/**/*.tsx",
155 ],
156
157 plugins: {
158 "@typescript-eslint": typescriptEslintEslintPlugin,
159 },
160
161 languageOptions: {
162 parser: tsParser,
163 },
164
165 rules: {
166 "@typescript-eslint/no-unused-vars": "off",
167 "@typescript-eslint/no-empty-function": "off",
168 "@typescript-eslint/no-explicit-any": "off",
169 "@typescript-eslint/no-non-null-assertion": "off",
170 "@typescript-eslint/no-var-requires": "off",
171 "prefer-rest-params": "off",
172 "@typescript-eslint/ban-ts-comment": "off",
173 "@typescript-eslint/no-non-null-asserted-optional-chain": "off",
174 "@typescript-eslint/ban-types": "off",
175 "@typescript-eslint/no-unused-expressions": "warn",
176 "@typescript-eslint/no-require-imports": "off",
177 "@typescript-eslint/no-empty-object-type": "warn",
178 },
179 },
180 ...medusaContentConfigs,
181 ]