fix: refactor AST parsing for custom ESLint rule
This commit is contained in:
@@ -20,14 +20,11 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
ImportDeclaration(node) {
|
ImportDeclaration(node) {
|
||||||
const importPath = node.source.value;
|
const importPath = node.source.value;
|
||||||
if (importPath.startsWith('../')) {
|
if (importPath.startsWith('../../')) {
|
||||||
const depth = importPath.match(/\.\.\//g).length;
|
context.report({
|
||||||
if (depth > 2) {
|
node,
|
||||||
context.report({
|
message: 'Importing files more than 2 directories up is not allowed.',
|
||||||
node,
|
});
|
||||||
message: 'Importing files more than 2 directories up is not allowed.',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-react-prefer-function-component": "^3.3.0",
|
"eslint-plugin-react-prefer-function-component": "^3.3.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.5",
|
"eslint-plugin-react-refresh": "^0.4.5",
|
||||||
"eslint-plugin-restrict-import-depth": "file:custom-eslint-rules",
|
"eslint-plugin-restrict-import-depth": "link:./custom-eslint-rules",
|
||||||
"eslint-plugin-simple-import-sort": "^12.0.0",
|
"eslint-plugin-simple-import-sort": "^12.0.0",
|
||||||
"eslint-plugin-storybook": "^0.6.15",
|
"eslint-plugin-storybook": "^0.6.15",
|
||||||
"path": "^0.12.7",
|
"path": "^0.12.7",
|
||||||
|
|||||||
650
pnpm-lock.yaml
generated
650
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@ import createSchedule from '@pages/background/lib/createSchedule';
|
|||||||
import switchSchedule from '@pages/background/lib/switchSchedule';
|
import switchSchedule from '@pages/background/lib/switchSchedule';
|
||||||
import type { UserSchedule } from '@shared/types/UserSchedule';
|
import type { UserSchedule } from '@shared/types/UserSchedule';
|
||||||
import useSchedules from '@views/hooks/useSchedules';
|
import useSchedules from '@views/hooks/useSchedules';
|
||||||
import React, { useEffect,useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import AddSchedule from '~icons/material-symbols/add';
|
import AddSchedule from '~icons/material-symbols/add';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user