Interest in adding "no-restricted-glob-paths" rule?
See original GitHub issueno-restricted-paths
doesn’t support globs.no-restricted-imports
supports globs/git-ignore-like but just as strings, no path resolving support.
So if there is an interested I think I could PR the no-restricted-glob-paths
rule. The functionality would be similar to https://github.com/vladimiry/tslint-rules-bunch.
I would prefer to use https://github.com/micromatch/picomatch module for globbing even though the minimatch
module is already used. The reason is that picomatch
is faster and supports arrays of patterns for both str / pattern
arguments on ismatch(str, pattern) function call.
Proposed configuration schema (basePath
props both on top/zone levels are optional):
schema: [{
type: 'object',
required: ["zones"],
properties: {
basePath: {type: ["string"]},
zones: {
type: "array",
minItems: 1,
items: {
type: "object",
required: ["target", "from"],
properties: {
basePath: {type: ["string"]},
target: {
anyOf: [
{type: "string"},
{type: "array", items: {type: "string"}},
],
},
from: {
anyOf: [
{type: "string"},
{type: "array", items: {type: "string"}},
],
},
},
additionalProperties: false,
},
},
},
additionalProperties: false
}]
Configuration example:
{
"plugins": [
"import"
],
"settings": {
"import/resolver": {
"typescript": {}
}
},
"rules": {
"import/no-restricted-glob-paths": [
"error",
{
"zones": [
{
"target": "src/electron-main/**/*",
"from": [
"./**/*",
"!./node_modules/**/*",
"!src/electron-main/**/*",
"!src/shared/**/*"
]
},
{
"basePath": "./src",
"target": [
"!./electron-main/database/entity/**/*",
"!./electron-main/database/validation.ts"
],
"from": [
"./electron-main/database/entity",
"./electron-main/database/entity/**/*"
]
}
]
}
]
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Interest in adding "no-restricted-glob-paths" rule? #1662
It seems like the first step would be adding path resolution configuration to no-restricted-imports , and then adding globs to no-restricted- ...
Read more >Education Department Releases Proposed Regulations to ...
The regulations propose to alleviate student loan debt burdens for borrowers whose schools closed or lied to them, who are totally and ...
Read more >Use the OS and Glob Python Packages to Manipulate File Paths
The glob() function uses the rules of Unix shell to help users organize their files. Unix shell follows fairly straight-forward rules to search ......
Read more >Prevent Imports From Being Used With ESLint - Webtips
Based on the paths property, you can pass along a patterns array with the same amount of items specifying a pattern for the...
Read more >Push rules - GitLab Docs
Override global push rules per project · On the top bar, select Main menu > Projects and find your project. · On the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What if we make
zones
array to include second object type? So we keep existingzones
object type and we change nothing in the respective logic. But we add a second object type and apply new logic with glob support for this object. If we go this way then there will be no breaking changes.So the
zones
array type would look like:Got it. So
v2.20.1 => v6.x eslint-plugin-import
bump is not considered.Unfortunately I would not be interested in implementing glob support in
no-restricted-paths
usingminimatch
module having known that there are better options (minimatch
by the way doesn’t declareengines.node
prop but it runs node 4,6,7 only on Travis). So closing the issue again, this time withwon't fix
status.