@stanfordspezi/spezi-web-configurations
Version:
Stanford Biodesign Digital Health Spezi Web Configurations
378 lines (355 loc) • 12.7 kB
JavaScript
var $5paZa$eslintjs = require("@eslint/js");
var $5paZa$globals = require("globals");
var $5paZa$eslintpluginreacthooks = require("eslint-plugin-react-hooks");
var $5paZa$typescripteslint = require("typescript-eslint");
var $5paZa$eslintpluginreact = require("eslint-plugin-react");
var $5paZa$eslintpluginpreferarrowfunctions = require("eslint-plugin-prefer-arrow-functions");
var $5paZa$eslintpluginprettierrecommended = require("eslint-plugin-prettier/recommended");
var $5paZa$eslintpluginimport = require("eslint-plugin-import");
function $parcel$exportWildcard(dest, source) {
Object.keys(source).forEach(function(key) {
if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {
return;
}
Object.defineProperty(dest, key, {
enumerable: true,
get: function get() {
return source[key];
}
});
});
return dest;
}
function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
//
// This source file is part of the Stanford Biodesign Digital Health Spezi Web Configurations open-source project
//
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md)
//
// SPDX-License-Identifier: MIT
//
var $87ab418b9b40430c$exports = {};
$parcel$export($87ab418b9b40430c$exports, "getEslintConfig", () => $87ab418b9b40430c$export$291d70cae7a280f1);
//
// This source file is part of the Stanford Biodesign Digital Health Spezi Web Configurations open-source project
//
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md)
//
// SPDX-License-Identifier: MIT
//
const $87ab418b9b40430c$export$291d70cae7a280f1 = ({ tsconfigRootDir: tsconfigRootDir, tsConfigsDirs: tsConfigsDirs = [], changeEveryRuleToWarning: changeEveryRuleToWarning })=>{
/**
* Completely ignores these directories
* */ const ignoredDirs = {
ignores: [
"dist",
"docs",
"out",
"coverage"
]
};
/**
* Basic recommended ESLint rules with overrides
* */ const eslintRules = [
(0, ($parcel$interopDefault($5paZa$eslintjs))).configs.recommended,
{
rules: {
"no-empty-pattern": "off"
}
}
];
/*
* Rules for import plugin.
* Auto rules reordering, prevents cycles, forces lack of extensions.
* */ const importRules = [
$5paZa$eslintpluginimport.flatConfigs.recommended,
$5paZa$eslintpluginimport.flatConfigs.typescript,
{
settings: {
"import/resolver": {
typescript: {
project: [
"./tsconfig.json",
...tsConfigsDirs
]
}
}
}
},
{
files: [
"**/*.{js,jsx,ts,tsx}"
],
rules: {
"import/order": [
"warn",
{
groups: [
"builtin",
"external",
"internal",
[
"parent",
"sibling"
]
],
pathGroupsExcludedImportTypes: [
"builtin"
],
"newlines-between": "never",
alphabetize: {
order: "asc",
caseInsensitive: true
}
}
],
"import/no-empty-named-blocks": "error",
"import/no-mutable-exports": "error",
"import/no-cycle": "error",
"import/extensions": [
"warn",
"always",
{
ts: "never",
tsx: "never",
js: "never",
jsx: "never",
mjs: "never"
}
],
"import/newline-after-import": "warn",
"import/no-anonymous-default-export": "warn",
"import/no-default-export": "error",
"import/no-duplicates": [
"error",
{
"prefer-inline": true
}
],
// false negatives
"import/namespace": [
"off"
]
}
}
];
/**
* Injects Node globals to Node tooling
* */ const nodeGlobals = {
files: [
"**/eslint.config.?(c)js",
"**/.prettierrc.?(c)js",
"**/postcss.config.?(c)js",
"**/tailwind.config.?(c)js"
],
languageOptions: {
globals: (0, ($parcel$interopDefault($5paZa$globals))).node
}
};
/**
* Enforces arrow functions instead of named function
* Automatically replaces every named function with an arrow function.
* */ const preferArrowFunctions = {
files: [
"**/*.{js,jsx,ts,tsx}"
],
plugins: {
"prefer-arrow-functions": $5paZa$eslintpluginpreferarrowfunctions
},
rules: {
"prefer-arrow-functions/prefer-arrow-functions": [
"warn",
{
allowedNames: [],
allowNamedFunctions: false,
allowObjectProperties: true,
classPropertiesAllowed: false,
disallowPrototype: false,
returnStyle: "unchanged",
singleReturnOnly: false
}
]
}
};
/**
* Configures TypeScript ESLint rules.
* This config is very strict, some repositories might need overrides.
*
* It relies on TSC type-checking, which might slow down linting for large codebases.
* Read more: https://typescript-eslint.io/getting-started/typed-linting/
* */ const tslint = {
extends: [
(0, ($parcel$interopDefault($5paZa$typescripteslint))).configs.strictTypeChecked,
(0, ($parcel$interopDefault($5paZa$typescripteslint))).configs.stylisticTypeChecked
],
files: [
"**/*.{ts,tsx}"
],
languageOptions: {
ecmaVersion: 2020,
globals: (0, ($parcel$interopDefault($5paZa$globals))).browser,
parserOptions: {
projectService: true,
tsconfigRootDir: tsconfigRootDir
}
},
rules: {
"@typescript-eslint/consistent-type-imports": [
"warn",
{
prefer: "type-imports",
fixStyle: "inline-type-imports",
disallowTypeAnnotations: false
}
],
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: {
attributes: false
}
}
],
"@typescript-eslint/no-empty-object-type": [
"error",
// `interface SpecificVariantProps extends VariantProps {}` is fine
{
allowInterfaces: "with-single-extends"
}
],
// make sure to `await` inside try…catch
"@typescript-eslint/return-await": [
"error",
"in-try-catch"
],
"@typescript-eslint/no-confusing-void-expression": [
"error",
{
ignoreArrowShorthand: true
}
],
// empty interfaces are fine, e.g. React component that extends other component, but with no additional props
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/array-type": [
"warn",
{
default: "array-simple",
readonly: "array-simple"
}
],
// allow unused vars prefixed with `_`
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_"
}
],
"@typescript-eslint/restrict-template-expressions": [
"error",
// numbers and booleans are fine in template strings
{
allowNumber: true,
allowBoolean: true
}
],
// notFound in Tanstack Router is thrown
"@typescript-eslint/only-throw-error": "off"
}
};
/**
* Configures react, react hooks plugin and customized rules
* */ const reactPlugins = [
(0, ($parcel$interopDefault($5paZa$eslintpluginreacthooks))).configs["recommended-latest"],
{
...(0, ($parcel$interopDefault($5paZa$eslintpluginreact))).configs.flat.recommended,
settings: {
react: {
version: "detect"
}
},
rules: {
...(0, ($parcel$interopDefault($5paZa$eslintpluginreact))).configs.flat.recommended.rules,
"react/jsx-curly-brace-presence": [
"warn",
{
props: "never",
children: "never",
propElementValues: "always"
}
],
"react/no-unescaped-entities": "off",
"react/jsx-fragments": [
"warn",
"syntax"
],
"react/prop-types": "off",
"react/self-closing-comp": [
"warn",
{
component: true,
html: false
}
]
}
},
(0, ($parcel$interopDefault($5paZa$eslintpluginreact))).configs.flat["jsx-runtime"]
];
/**
* Disables default export rule for tools that need to use it.
* */ const ignoreDefaultExportRule = {
files: [
"{app,pages}/**/*.ts?(x)",
"**/playwright.config.ts",
"**/tailwind.config.ts",
"**/vite.config.ts",
"**/*.stories.ts?(x)",
"**/.storybook/**/*.ts?(x)"
],
rules: {
"import/no-default-export": "off"
}
};
/**
* Transforms ALL rules severities to 'warn'
* */ const transformAllRulesToWarn = {
rules: {},
languageOptions: {},
processor: {
preprocess: (text)=>[
text
],
postprocess: (messages)=>messages[0].map((message)=>({
...message,
severity: 1
}))
}
};
/**
* Forces correct prettier formatting with auto-fix support
* */ const prettierPlugin = (0, ($parcel$interopDefault($5paZa$eslintpluginprettierrecommended)));
return (0, ($parcel$interopDefault($5paZa$typescripteslint))).config(ignoredDirs, ...eslintRules, ...importRules, nodeGlobals, tslint, preferArrowFunctions, ...reactPlugins, prettierPlugin, ignoreDefaultExportRule, changeEveryRuleToWarning ? transformAllRulesToWarn : {});
};
var $7eef3883c4457fd8$exports = {};
$parcel$export($7eef3883c4457fd8$exports, "prettierConfig", () => $7eef3883c4457fd8$export$afe7f6f62e0066a0);
//
// This source file is part of the Stanford Biodesign Digital Health Spezi Web Configurations open-source project
//
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md)
//
// SPDX-License-Identifier: MIT
//
const $7eef3883c4457fd8$export$afe7f6f62e0066a0 = {
plugins: [
"prettier-plugin-tailwindcss"
],
experimentalTernaries: true
};
$parcel$exportWildcard(module.exports, $87ab418b9b40430c$exports);
$parcel$exportWildcard(module.exports, $7eef3883c4457fd8$exports);
//# sourceMappingURL=index.js.map