blurts-server/.eslintrc.json

174 строки
6.1 KiB
JSON

{
"env": {
"browser": true,
"es2022": true,
"node": true,
"jest": true
},
"extends": [
"plugin:jsdoc/recommended",
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"next/core-web-vitals",
"next",
"plugin:import/recommended",
"plugin:import/typescript"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["header", "jsdoc", "@typescript-eslint", "check-file", "jest"],
"rules": {
"header/header": [
"warn",
"block",
" This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/. ",
2
],
// For some reason `eqeqeq` is not in the recommended set, but we try to
// avoid implicit type casting, cause that's where bugs lurk:
"eqeqeq": "error",
"jsdoc/tag-lines": ["error", "any", { "startLines": 1 }],
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param-type": "off",
"jsdoc/require-param-description": "off",
"jsdoc/require-property-description": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-returns-type": "off",
"jsdoc/require-returns-description": "off",
// Unused vars explicitly marked as such with an understore prefix are allowed:
"no-unused-vars": [
"off",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
// Unused vars that start with an understore are allowed to be unused:
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"no-restricted-imports": [
"error",
{
"patterns": [
{
"group": ["**/hooks/*"],
"importNames": ["useGlean", "useGa"],
"message": "Please refrain from using this hook standalone. The preferred way to record telemetry is through `useTelemetry`."
}
],
"paths": [
{
// react-aria's <VisuallyHidden> component adds inline styles to
// visually hide its children, but our Content Security Policy
// disallows inline styles. By adding the equivalent styles to a CSS
// file, which automatically gets added to our Content Security
// Policy, our own <VisuallyHidden> component avoids this
// restriction.
"name": "react-aria",
"importNames": ["VisuallyHidden"],
"message": "Please use the <VisuallyHidden> component from `/src/app/components/server/VisuallyHidden.tsx` instead of the one from react-aria, since the latter's (inline) styles will be stripped by our Content Security Policy."
},
{
"name": "next-auth",
"importNames": ["getServerSession"],
"message": "Please use the `getServerSession` wrapper function from `/src/app/functions/server/getServerSession.ts` instead of the one from next-auth, since the latter's doesn't enforce passing the auth configuration object, resulting in broken sessions."
},
{
"name": "next-auth/next",
"importNames": ["getServerSession"],
"message": "Please use the `getServerSession` wrapper function from `/src/app/functions/server/getServerSession.ts` instead of the one from next-auth, since the latter's doesn't enforce passing the auth configuration object, resulting in broken sessions."
},
{
"name": "server-only",
"message": "Please import `/src/app/functions/server/notInClientComponent` instead of `server-only`, since the latter will also error in non-Next.js environments like cron jobs."
}
]
}
],
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-ignore": "allow-with-description"
}
],
"check-file/filename-naming-convention": [
"error",
{
"**/*.{js,css} !src/db/migrations": "CAMEL_CASE"
},
{
"ignoreMiddleExtensions": true
}
]
},
"overrides": [
{
"files": ["next-env.d.ts"],
"rules": {
"header/header": "off"
}
},
{
"files": ["**/*.test.{ts,tsx,js}"],
"plugins": ["jest"],
"extends": ["plugin:jest/recommended"]
},
{
"files": [
"src/app.js",
"src/utils/redisMock.js",
"src/app/functions/server/breachResolution.ts"
],
"rules": {
"jsdoc/no-undefined-types": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"import/no-named-as-default-member": "off",
"import/no-unresolved": "off"
}
},
{
// Only enable rules that depend on type checking on TS files.
"files": ["**/*.{ts,tsx}"],
"extends": [
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"parserOptions": {
// See https://typescript-eslint.io/linting/typed-linting/#specifying-tsconfigs
// Needed for `plugin:@typescript-eslint/recommended-requiring-type-checking`
// to avoid this error:
// > You have used a rule which requires parserServices to be generated.
// > You must therefore provide a value for the "parserOptions.project"
// > property for @typescript-eslint/parser.
"project": "tsconfig.json"
},
"rules": {
// These rules trigger lots of times; possibly we can enable them later:
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off"
}
}
],
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": true,
"node": true
}
}
}