
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
eslint-plugin-import-srclimits
Advanced tools
Limit import source from some special folder in configuration
stable_version
>= 1.0.0
Limit import source from some special folder in configuration
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-import-srclimits
:
$ npm install eslint-plugin-import-srclimits --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-import-srclimits
globally.
Add import-srclimit
to the plugins section of your .eslintrc.js
configuration file. You can omit the eslint-plugin-
prefix:
Set parserOptions.sourceType
value as module
in your configuration.
module.exports = {
// ...
"plugins": [
"import-srclimits"
],
"parserOptions": {
"ecmaVersion": 2015,
"sourceType": "module"
}
// ...
};
Then configure the rules you want to use under the rules section.
The effect is: The files match in
files
pattern, can only import target match insource
pattern
module.exports = {
// ...
"rules": {
"import-srclimits/srclimits": [
"error",
{
"files": ["./src/**/*.{js,vue,jsx}"],
"source": ["./src/**/*.*", "node_modules/**", "!./mock/**/*.*"],
"errMsg": "The code of the files in the src folder, can't import source file in ./mock/**"
}
]
}
// ...
};
option files
& source
can accepts glob-pattern
, regular-expression
, function(str){/* return fasle|true; */}
module.exports = {
// ...
"rules": {
"import-srclimits/srclimits": [
"warn",
{
"files": ["./src/**/*.{js,vue,jsx}"],
"source": [
(str) => (str.indexOf('util') == -1),
/os/g
],
"errMsg": "Browser code could not use node module 'util' & 'os'!!!"
}
]
}
// ...
};
see more: anymatch
srclimits
valid
✓ import qs from 'qs'; (48ms)
✓ import abc from 'qs/abc';
✓ import kapp from '@scopename/kapp';
✓ import abc from '@scopename/bbb/abc';
✓ import clone from '../utils/clone.js';
✓ import '../utils/clone.js';
✓ import '../utils/clone';
✓ import { clone } from '../utils/index.js';
✓ import { clone } from '../utils/';
✓ import { clone } from '../utils';
✓ import { clone as copy } from '../utils';
✓ import * as _ from '../utils/index.js';
invalid
✓ import '../../mock/storage.js';
✓ import '../../mock/storage';
✓ import storage from '../../mock/storage.js';
✓ import storage from '../../mock/storage';
✓ import '../../mock/utils';
✓ import '../../mock/utils/';
✓ import * as _ from '../../mock/utils/index.js';
✓ import { addStyleTag } from '../../mock/utils/';
✓ import { addStyleTag as injectStyleDom } from '../../mock/utils/index';
✓ // multiple lines
import { clone } from '../utils/'; // ✓
import { base } from '../base/index'; // ✓
import { addStyleTag as injectStyleDom } from '../../mock/utils/index'; // ✘
22 passing
Created by yeoman tool.
FAQs
Limit import source from some special folder in configuration
The npm package eslint-plugin-import-srclimits receives a total of 11 weekly downloads. As such, eslint-plugin-import-srclimits popularity was classified as not popular.
We found that eslint-plugin-import-srclimits 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.