
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
eslint-plugin-best-practices
Advanced tools
an eslint plugin to enforce some best practices
npm install eslint-plugin-best-practices
// eslintrc.js
module.exports = {
plugins: ['eslint-plugin-best-practices'],
rules: {
'best-practices/explicit-internal-boundaries': ['error'],
'best-practices/isolated-route-files': ['error', {
'routeFiles': ['app/*/routes/**'],
'ignoredRouteFiles': ['.*', '**/*.css'],
}]
},
}
module.exports = {
rules: {
'best-practices/explicit-internal-boundaries': ['error'],
},
};
This rule enforces explicit boundaries for importing files from internal
directories. It ensures that files within an internal
folder can only be imported by files that reside within the same module or directory tree. This rule prevents access to internal-specific code from outside its designated module, reinforcing module encapsulation and promoting cleaner, more maintainable code architecture.
Enforcing explicit internal boundaries:
Here is an example of how you might configure this rule in your ESLint setup:
module.exports = {
rules: {
'best-practices/explicit-internal-boundaries': ['error'],
},
};
Here is an example of how this rule applies to a typical project structure:
./app
├── module-a
│ ├── internal
│ │ ├── helper-a.ts
│ │ └── config-a.ts
│ └── service-a.ts
├── module-b
│ ├── internal
│ │ └── helper-b.ts
│ └── service-b.ts
└── common
└── utils.ts
With the explicit-internal-boundaries
rule applied:
service-a.ts
can import helper-a.ts
or config-a.ts
because they are in the same module.service-b.ts
cannot import helper-a.ts
or config-a.ts
because it crosses module boundaries.utils.ts
in the common
directory cannot import any files from internal
directories in either module-a
or module-b
.This rule ensures that each module's internals remain isolated, reinforcing clear and robust architectural boundaries within the application.
best-practices/isolated-route-files
module.exports = {
rules: {
'best-practices/isolated-route-files': ['error', {
'routeFiles': ['app/*/routes/**'],
'ignoredRouteFiles': ['.*', '**/*.css'],
}],
},
};
This rule enforces isolation for route or page files, based on file-based routing conventions. It ensures that files designated as route handlers remain decoupled from the rest of the application, prohibiting imports from these files into any other part of the application. This rule supports a clean separation between routing mechanisms and business logic, adhering to modern frontend architecture practices.
Maintaining isolation of route files:
Here is an example of how you might configure this rule in your ESLint setup:
module.exports = {
rules: {
'best-practices/isolated-route-files': ['error', {
'routeFiles': ['app/*/routes/**'],
'ignoredRouteFiles': ['.*', '**/*.css', '**/*.test.{ts,tsx}'],
}],
},
};
Here is an example of the application structure with route files and the expected enforcement by this rule:
./app
├── analytics
│ ├── config.ts
│ └── routes
│ ├── api.ts
│ └── index.tsx
├── auth
│ ├── config.ts
│ └── routes
│ ├── auth.auth0.callback.tsx
│ ├── login.tsx
│ └── logout.tsx
├── broadcasts-notifications
│ ├── config.ts
│ └── routes
│ ├── $notificationId.tsx
│ └── _layout.tsx
With the isolated-route-files
rule applied:
api.ts
, index.tsx
, login.tsx
, etc., within any routes
directory are prohibited from being imported into other parts of the application.This rule promotes a disciplined use of routing files, keeping them isolated as per the file-based routing conventions in modern web development frameworks.
FAQs
an eslint plugin to enforce some best practices
The npm package eslint-plugin-best-practices receives a total of 301 weekly downloads. As such, eslint-plugin-best-practices popularity was classified as not popular.
We found that eslint-plugin-best-practices demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.