UNPKG

@truenine/eslint9-config

Version:

ESLint 9 configuration package for Compose Client projects with TypeScript, Vue, and modern JavaScript support

191 lines (190 loc) 4.51 kB
//#region src/defaults/index.ts const defaultUnocssConfig = { attributify: true, strict: true }; const defaultVueConfig = { vueVersion: 3, overrides: { "vue/html-self-closing": ["error", { html: { void: "always", normal: "always", component: "always" } }], "vue/html-comment-content-spacing": [ "error", "always", { exceptions: [] } ], "vue/html-comment-indent": ["error", 2], "vue/html-indent": [ "error", 2, { baseIndent: 0, alignAttributesVertically: true } ], "vue/define-emits-declaration": ["error", "type-literal"], "vue/define-props-declaration": ["error", "type-based"], "vue/define-macros-order": ["error", { order: [ "defineProps", "defineEmits", "defineModel", "defineSlots" ], defineExposeLast: true }], "vue/block-order": ["error", { order: [ "script", "template", "style" ] }], "vue/attributes-order": ["error", { order: [ "DEFINITION", "LIST_RENDERING", "CONDITIONALS", "RENDER_MODIFIERS", "GLOBAL", "UNIQUE", "TWO_WAY_BINDING", "OTHER_DIRECTIVES", "OTHER_ATTR", "EVENTS", "CONTENT" ] }], "vue/v-on-event-hyphenation": [ "error", "never", { autofix: true } ], "vue/attribute-hyphenation": [ "error", "never", { ignoreTags: [ "i-", "v-", "v-bind" ] } ], "vue/prop-name-casing": ["error", "camelCase"], "vue/component-name-in-template-casing": [ "error", "PascalCase", { ignores: [ "router-view", "router-link", "scroll-view" ], registeredComponentsOnly: false } ] } }; const defaultJsConfig = { overrides: { "no-inline-comments": "error", "unicorn/no-useless-spread": "error", "curly": ["error", "all"], "no-undefined": "error", "no-cond-assign": ["error", "always"], "no-constant-condition": "error", "no-restricted-syntax": "error", "no-global-assign": "error", "no-unused-vars": "error", "no-var": "error", "prefer-const": ["error", { destructuring: "any", ignoreReadBeforeAssign: false }] } }; const defaultTsConfig = { overrides: { "ts/no-unsafe-assignment": "off", "ts/no-unsafe-call": "off", "ts/no-unsafe-argument": "off", "ts/no-unsafe-return": "off", "ts/member-ordering": ["error"], "ts/no-extra-non-null-assertion": "error", "ts/no-non-null-assertion": "error", "ts/no-explicit-any": ["error", { fixToUnknown: true, ignoreRestArgs: true }], "ts/no-namespace": "error", "ts/no-unused-vars": ["error", { vars: "all", args: "after-used", ignoreRestSiblings: false }] } }; const defaultFormatterConfig = { css: "prettier", html: "prettier", prettierOptions: { printWidth: 160, tabWidth: 2, arrowParens: "always", vueIndentScriptAndStyle: true, useTabs: false, singleQuote: true, jsxSingleQuote: true, trailingComma: "all", bracketSpacing: true } }; /** * 严格 ts 模式 的默认配置 * * 这些配置需要 配置 parserOptions 和 tsconfigPath 等 * @see https://typescript-eslint.io/getting-started/typed-linting */ const defaultStrictTsConfig = { overrides: { "ts/no-unsafe-assignment": "off", "ts/no-unsafe-call": "off", "ts/no-unsafe-argument": "off", "ts/no-unsafe-return": "off", "ts/no-floating-promises": "error" } }; const defaultStylisticConfig = { jsx: true, indent: 2, quotes: "single", semi: false, overrides: { "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }], "style/brace-style": ["error", "1tbs"], "style/arrow-parens": ["error", "always"] } }; const defaultTestConfig = { overrides: { "no-console": "off", "ts/unbound-method": "off", "ts/no-unsafe-argument": "off", "ts/no-unsafe-assignment": "off", "ts/no-unsafe-member-access": "off", "ts/no-unsafe-call": "off", "ts/no-unsafe-return": "off" } }; function mergeWithDefaults(value, defaults) { if (defaults === false || defaults === null || defaults === void 0) { if (value === true) return true; if (value === false || value === null) return false; return value; } if (value === void 0) return defaults; if (value === false || value === null) return false; if (value === true) return defaults; if (typeof value === "object" && typeof defaults === "object") return { ...defaults, ...value }; return value; } //#endregion export { defaultFormatterConfig, defaultJsConfig, defaultStrictTsConfig, defaultStylisticConfig, defaultTestConfig, defaultTsConfig, defaultUnocssConfig, defaultVueConfig, mergeWithDefaults }; //# sourceMappingURL=index.js.map