2023-10-05 18:51:30 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
2023-09-12 17:52:22 +00:00
|
|
|
const { builtinModules } = require('module');
|
2023-09-12 17:50:06 +00:00
|
|
|
|
2023-10-05 18:51:30 +00:00
|
|
|
/** @type {import("@types/eslint").Linter.Config} */
|
2021-03-16 18:37:45 +00:00
|
|
|
module.exports = {
|
2023-07-03 12:59:43 +00:00
|
|
|
extends: [
|
|
|
|
'plugin:@typescript-eslint/recommended-type-checked',
|
|
|
|
'plugin:@typescript-eslint/stylistic-type-checked',
|
|
|
|
'prettier',
|
|
|
|
],
|
2021-03-16 18:37:45 +00:00
|
|
|
parser: '@typescript-eslint/parser',
|
2023-07-03 12:59:43 +00:00
|
|
|
parserOptions: {
|
|
|
|
project: ['./packages/*/tsconfig.json', './tsconfig.eslint.json'],
|
|
|
|
tsconfigRootDir: __dirname,
|
|
|
|
},
|
2022-06-22 15:59:49 +00:00
|
|
|
plugins: ['@typescript-eslint', 'prettier', 'no-only-tests'],
|
2021-03-16 18:37:45 +00:00
|
|
|
rules: {
|
2023-07-03 12:59:43 +00:00
|
|
|
// These off/configured-differently-by-default rules fit well for us
|
|
|
|
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
|
2023-09-05 18:03:21 +00:00
|
|
|
'@typescript-eslint/no-unused-vars': [
|
|
|
|
'error',
|
|
|
|
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
|
|
|
|
],
|
2023-07-03 12:59:43 +00:00
|
|
|
'no-only-tests/no-only-tests': 'error',
|
|
|
|
'@typescript-eslint/no-shadow': ['error'],
|
|
|
|
'no-console': 'warn',
|
|
|
|
|
|
|
|
// Todo: do we want these?
|
|
|
|
'@typescript-eslint/array-type': 'off',
|
2021-04-21 16:14:44 +00:00
|
|
|
'@typescript-eslint/ban-ts-comment': 'off',
|
2023-07-03 12:59:43 +00:00
|
|
|
'@typescript-eslint/class-literal-property-style': 'off',
|
|
|
|
'@typescript-eslint/consistent-indexed-object-style': 'off',
|
|
|
|
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
|
|
'@typescript-eslint/dot-notation': 'off',
|
|
|
|
'@typescript-eslint/no-base-to-string': 'off',
|
2021-04-01 16:25:28 +00:00
|
|
|
'@typescript-eslint/no-empty-function': 'off',
|
2023-07-03 12:59:43 +00:00
|
|
|
'@typescript-eslint/no-floating-promises': 'off',
|
|
|
|
'@typescript-eslint/no-misused-promises': 'off',
|
|
|
|
'@typescript-eslint/no-redundant-type-constituents': 'off',
|
2022-01-06 21:32:24 +00:00
|
|
|
'@typescript-eslint/no-this-alias': 'off',
|
2023-07-03 12:59:43 +00:00
|
|
|
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
|
|
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
|
|
'@typescript-eslint/no-unsafe-call': 'off',
|
|
|
|
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
|
|
'@typescript-eslint/no-unsafe-return': 'off',
|
|
|
|
'@typescript-eslint/prefer-nullish-coalescing': 'off',
|
2023-07-12 07:11:46 +00:00
|
|
|
'@typescript-eslint/prefer-optional-chain': 'off',
|
2023-07-03 12:59:43 +00:00
|
|
|
'@typescript-eslint/prefer-string-starts-ends-with': 'off',
|
|
|
|
'@typescript-eslint/require-await': 'off',
|
|
|
|
'@typescript-eslint/restrict-plus-operands': 'off',
|
|
|
|
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
|
|
'@typescript-eslint/sort-type-constituents': 'off',
|
|
|
|
'@typescript-eslint/unbound-method': 'off',
|
2023-07-12 07:14:48 +00:00
|
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
2023-07-03 12:59:43 +00:00
|
|
|
|
|
|
|
// These rules enabled by the preset configs don't work well for us
|
|
|
|
'@typescript-eslint/await-thenable': 'off',
|
2021-03-16 18:37:45 +00:00
|
|
|
'prefer-const': 'off',
|
|
|
|
},
|
2022-08-23 19:55:03 +00:00
|
|
|
overrides: [
|
2023-09-12 17:52:22 +00:00
|
|
|
{
|
2023-09-12 17:50:06 +00:00
|
|
|
// Ensure Node builtins aren't included in Astro's server runtime
|
|
|
|
files: ['packages/astro/src/runtime/**/*.ts'],
|
|
|
|
rules: {
|
2023-09-12 17:52:22 +00:00
|
|
|
'no-restricted-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
paths: [...builtinModules],
|
|
|
|
patterns: ['node:*'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-09-12 17:50:06 +00:00
|
|
|
},
|
2023-10-05 18:51:30 +00:00
|
|
|
{
|
|
|
|
files: ['packages/astro/src/runtime/client/**/*.ts'],
|
|
|
|
env: {
|
|
|
|
browser: true,
|
|
|
|
},
|
|
|
|
},
|
2022-08-23 19:55:03 +00:00
|
|
|
{
|
2022-09-13 21:23:59 +00:00
|
|
|
files: ['packages/**/test/*.js', 'packages/**/*.js'],
|
2022-08-23 19:55:03 +00:00
|
|
|
env: {
|
|
|
|
mocha: true,
|
|
|
|
},
|
|
|
|
globals: {
|
|
|
|
globalThis: false, // false means read-only
|
|
|
|
},
|
|
|
|
rules: {
|
|
|
|
'no-console': 'off',
|
|
|
|
},
|
|
|
|
},
|
2022-10-03 15:37:21 +00:00
|
|
|
{
|
|
|
|
files: ['packages/integrations/**/*.ts'],
|
|
|
|
rules: {
|
|
|
|
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
|
|
|
|
},
|
|
|
|
},
|
2023-03-01 08:46:06 +00:00
|
|
|
{
|
|
|
|
files: ['benchmark/**/*.js'],
|
|
|
|
rules: {
|
2023-07-03 12:59:43 +00:00
|
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
2023-03-01 08:46:06 +00:00
|
|
|
'no-console': 'off',
|
|
|
|
},
|
|
|
|
},
|
2022-08-23 19:55:03 +00:00
|
|
|
],
|
2021-03-16 18:37:45 +00:00
|
|
|
};
|