Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
eslint-plugin-absolute-imports-only
Advanced tools
A (zero-dependency!) eslint plugin that enforces absolute imports on your codebase.
You must have a baseUrl
defined in either tsconfig.json
or jsconfig.json
. This plugin does not currently work with paths
!
If you are working with a full-stack project, e.g. your Frontend project is at /front-end
then you need to provide the path to tsconfig.json
or jsconfig.json
in eslint
configuration file
Example:
...
settings: {
"absolute-imports-only": {
project: path.resolve(__dirname, 'tsconfig.json'),
},
},
npm i --save-dev eslint-plugin-absolute-imports-only
yarn add -D eslint-plugin-absolute-imports-only
eslint-plugin-absolute-imports-only
to your eslint plugins
sectionabsolute-imports-only/only-absolute-imports
to your eslint rules
sectiontrue
)Enabling this option will make the plugin only fix the imports for .(ts|tsx|js|jsx|json)
files
1
)Minimum level for the plugin to start fixing
Example:
minLevel
is set to 0
then all imports will be fixedEg: This below import statement
// src/components/componentB.tsx
import ComponentA from './componentA'
will be fixed to
// src/components/componentB.tsx
import ComponentA from 'src/components/componentA`
minLevel
is set to 1
then only files that are not in the same directory with current files are fixed=> This below import statement won't be fixed
// src/components/componentB.tsx
import ComponentA from './componentA'
MIT
1.0.1 (04/21/22)
FAQs
Eslint rule enforcing absolute imports
The npm package eslint-plugin-absolute-imports-only receives a total of 2,930 weekly downloads. As such, eslint-plugin-absolute-imports-only popularity was classified as popular.
We found that eslint-plugin-absolute-imports-only 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.