@stanfordspezi/spezi-web-configurations
v0.7.0
Published
Stanford Biodesign Digital Health Spezi Web Configurations
Maintainers
Readme
Biodesign Digital Health Spezi Web Configurations
Getting Started
A shared linting and formatter configurations. Uses Prettier and ESLint. Pre-configured for you to easily plug into your codebases.
Configurations are opinionated and strict. We aim to catch as many possible mistakes or elements we consider harmful practices early. Some rules are meant to be broken once in a while, with an explanation comment around them.
Installation
Install dependencies:
npm install --save-dev prettier eslint @stanfordspezi/spezi-web-configurationsCreate eslint.config.js file.
If aiming for React, use:
const { getEslintReactConfig } = require('@stanfordspezi/spezi-web-configurations')
module.exports = getEslintReactConfig({ tsconfigRootDir: __dirname })If aiming for Node application, use:
const { getEslintNodeConfig } = require('@stanfordspezi/spezi-web-configurations')
module.exports = getEslintNodeConfig({ tsconfigRootDir: __dirname })Create .prettierrc.js file:
const { prettierConfig } = require("@stanfordspezi/spezi-web-configurations");
module.exports = prettierConfig;Now, when you run eslint . --fix, code is going to be linted and formatted.
ESLint customization
We aim to make this config mostly plug and play. You can adjust ESLint to your needs by passing additional configuration pieces.
module.exports = [
...getEslintNodeConfig({ tsconfigRootDir: __dirname }),
{
ignores: ["lib/**/*"], // Ignore generated build files
},
{
rules: {
"@typescript-eslint/no-non-null-assertion": "off", // ignore unwanted rule
},
},
]For more complex scenarios, we expose smaller pieces of configuration. You can use them and do micro-adjustments. This is not the recommended approach.
const {
getEslintRules,
getNodeGlobals,
getPreferArrowFunctions,
getReactPlugins,
getPrettierPlugin,
getTslint,
} = require("@stanfordspezi/spezi-web-configurations");
const tseslint = require("typescript-eslint");
module.exports = tseslint.config(
...getEslintRules(),
getNodeGlobals(),
{
...getTslint(),
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
projectService: true,
tsconfigRootDir,
},
},
},
getPreferArrowFunctions(),
...getReactPlugins(),
...getPrettierPlugin(),
);License
This project is licensed under the MIT License. See Licenses for more information.
Contributors
This project is developed as part of the Stanford Byers Center for Biodesign at Stanford University. See CONTRIBUTORS.md for a full list of all Next.js Template contributors.

