mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
eslint no-restricted-path false positive: bug caused by dir names that start with "index". (#46544) (#49852)
* index* to index.{ts,tsx} * Added test. * Added invalid test. * Added js.
This commit is contained in:
parent
cfd91426bb
commit
0e2e40ef3c
3 changed files with 53 additions and 2 deletions
|
@ -364,10 +364,10 @@ module.exports = {
|
|||
'!src/core/server/*.test.mocks.ts',
|
||||
|
||||
'src/plugins/**/public/**/*',
|
||||
'!src/plugins/**/public/index*',
|
||||
'!src/plugins/**/public/index.{js,ts,tsx}',
|
||||
|
||||
'src/plugins/**/server/**/*',
|
||||
'!src/plugins/**/server/index*',
|
||||
'!src/plugins/**/server/index.{js,ts,tsx}',
|
||||
],
|
||||
allowSameFolder: true,
|
||||
},
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/* eslint-disable */
|
|
@ -172,6 +172,27 @@ ruleTester.run('@kbn/eslint/no-restricted-paths', rule, {
|
|||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
// Check if dirs that start with 'index' work correctly.
|
||||
code: 'import { X } from "./index_patterns"',
|
||||
filename: path.join(__dirname, './files/no_restricted_paths/server/b.js'),
|
||||
options: [
|
||||
{
|
||||
basePath: __dirname,
|
||||
zones: [
|
||||
{
|
||||
target: ['files/no_restricted_paths/(public|server)/**/*'],
|
||||
from: [
|
||||
'files/no_restricted_paths/server/**/*',
|
||||
'!files/no_restricted_paths/server/index.{ts,tsx}',
|
||||
],
|
||||
allowSameFolder: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
invalid: [
|
||||
|
@ -369,5 +390,34 @@ ruleTester.run('@kbn/eslint/no-restricted-paths', rule, {
|
|||
},
|
||||
],
|
||||
},
|
||||
|
||||
{
|
||||
// Don't use index*.
|
||||
// It won't work with dirs that start with 'index'.
|
||||
code: 'import { X } from "./index_patterns"',
|
||||
filename: path.join(__dirname, './files/no_restricted_paths/server/b.js'),
|
||||
options: [
|
||||
{
|
||||
basePath: __dirname,
|
||||
zones: [
|
||||
{
|
||||
target: ['files/no_restricted_paths/(public|server)/**/*'],
|
||||
from: [
|
||||
'files/no_restricted_paths/server/**/*',
|
||||
'!files/no_restricted_paths/server/index*',
|
||||
],
|
||||
allowSameFolder: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
errors: [
|
||||
{
|
||||
message: 'Unexpected path "./index_patterns" imported in restricted zone.',
|
||||
line: 1,
|
||||
column: 19,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue