2022-12-21 02:08:20 +03:00
|
|
|
/* eslint-env node */
|
|
|
|
|
2023-08-08 20:38:37 +03:00
|
|
|
const { node: restrictedImports } = require('@uniswap/eslint-config/restrictedImports')
|
2022-12-21 02:08:20 +03:00
|
|
|
require('@uniswap/eslint-config/load')
|
|
|
|
|
2023-05-16 23:53:22 +03:00
|
|
|
const rulesDirPlugin = require('eslint-plugin-rulesdir')
|
|
|
|
rulesDirPlugin.RULES_DIR = 'eslint_rules'
|
|
|
|
|
2022-12-21 02:08:20 +03:00
|
|
|
module.exports = {
|
2023-05-16 23:53:22 +03:00
|
|
|
extends: ['@uniswap/eslint-config/react'],
|
|
|
|
plugins: ['rulesdir'],
|
2023-03-29 23:25:30 +03:00
|
|
|
overrides: [
|
2023-05-02 18:26:07 +03:00
|
|
|
{
|
|
|
|
files: ['**/*'],
|
|
|
|
rules: {
|
|
|
|
'multiline-comment-style': ['error', 'separate-lines'],
|
2023-05-24 21:31:40 +03:00
|
|
|
'rulesdir/no-undefined-or': 'error',
|
2023-05-02 18:26:07 +03:00
|
|
|
},
|
|
|
|
},
|
2023-04-13 22:43:47 +03:00
|
|
|
{
|
|
|
|
// Configuration/typings typically export objects/definitions that are used outside of the transpiled package
|
|
|
|
// (eg not captured by the tsconfig). Because it's typical and not exceptional, this is turned off entirely.
|
|
|
|
files: ['**/*.config.*', '**/*.d.ts'],
|
|
|
|
rules: {
|
|
|
|
'import/no-unused-modules': 'off',
|
|
|
|
},
|
|
|
|
},
|
2023-03-29 23:25:30 +03:00
|
|
|
{
|
|
|
|
files: ['**/*.ts', '**/*.tsx'],
|
|
|
|
rules: {
|
2023-09-15 22:24:00 +03:00
|
|
|
'@typescript-eslint/no-restricted-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
...restrictedImports,
|
|
|
|
paths: [
|
|
|
|
...restrictedImports.paths,
|
|
|
|
{
|
|
|
|
name: '@uniswap/smart-order-router',
|
|
|
|
message: 'Only import types, unless you are in the client-side SOR, to preserve lazy-loading.',
|
|
|
|
allowTypeImports: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-04-20 23:43:31 +03:00
|
|
|
'import/no-restricted-paths': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
zones: [
|
|
|
|
{
|
|
|
|
target: ['src/**/*[!.test].ts', 'src/**/*[!.test].tsx'],
|
|
|
|
from: 'src/test-utils',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-03-29 23:25:30 +03:00
|
|
|
'no-restricted-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
paths: [
|
2023-04-21 00:12:43 +03:00
|
|
|
{
|
|
|
|
name: 'moment',
|
|
|
|
// tree-shaking for moment is not configured because it degrades performance - see craco.config.cjs.
|
|
|
|
message: 'moment is not configured for tree-shaking. If you use it, update the Webpack configuration.',
|
|
|
|
},
|
2023-03-29 23:25:30 +03:00
|
|
|
{
|
|
|
|
name: 'zustand',
|
|
|
|
importNames: ['default'],
|
|
|
|
message: 'Default import from zustand is deprecated. Import `{ create }` instead.',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2023-09-22 05:38:17 +03:00
|
|
|
'no-restricted-syntax': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
selector: ':matches(ExportAllDeclaration)',
|
|
|
|
message: 'Barrel exports bloat the bundle size by preventing tree-shaking.',
|
|
|
|
},
|
|
|
|
],
|
2023-03-29 23:25:30 +03:00
|
|
|
},
|
|
|
|
},
|
2023-07-21 20:15:51 +03:00
|
|
|
{
|
|
|
|
files: ['**/*.ts', '**/*.tsx'],
|
|
|
|
excludedFiles: ['src/analytics/*'],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-imports': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
paths: [
|
|
|
|
{
|
|
|
|
name: '@uniswap/analytics',
|
|
|
|
message: `Do not import from '@uniswap/analytics' directly. Use 'analytics' instead.`,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2023-03-29 23:25:30 +03:00
|
|
|
],
|
2022-12-21 02:08:20 +03:00
|
|
|
}
|