@redhat-cloud-services/eslint-config-redhat-cloud-services 2.0.3 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -48
- package/index.d.ts +36 -0
- package/index.js +34 -33
- package/index.js.map +1 -0
- package/lib/rules/deprecated-packages.d.ts +16 -0
- package/lib/rules/deprecated-packages.js +45 -38
- package/lib/rules/deprecated-packages.js.map +1 -0
- package/lib/rules/disallow-fec-relative-imports.d.ts +16 -0
- package/lib/rules/disallow-fec-relative-imports.js +71 -88
- package/lib/rules/disallow-fec-relative-imports.js.map +1 -0
- package/lib/rules/disallow-pf-migrated-components.d.ts +13 -0
- package/lib/rules/disallow-pf-migrated-components.js +45 -49
- package/lib/rules/disallow-pf-migrated-components.js.map +1 -0
- package/lib/rules/forbid-pf-relative-imports.d.ts +17 -0
- package/lib/rules/forbid-pf-relative-imports.js +149 -183
- package/lib/rules/forbid-pf-relative-imports.js.map +1 -0
- package/lib/rules/insights-disallow-custom-axios.d.ts +15 -0
- package/lib/rules/insights-disallow-custom-axios.js +28 -0
- package/lib/rules/insights-disallow-custom-axios.js.map +1 -0
- package/lib/rules/no-chrome-api-call-from-window.d.ts +11 -0
- package/lib/rules/no-chrome-api-call-from-window.js +19 -16
- package/lib/rules/no-chrome-api-call-from-window.js.map +1 -0
- package/package.json +29 -26
- package/prettier.config.js +0 -9
package/README.md
CHANGED
|
@@ -1,52 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frontend-components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Monorepo of Red Hat Cloud services Components for applications in a React.js environment.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
## Packages
|
|
6
|
+
* [utils](https://github.com/RedHatInsights/frontend-components/tree/master/packages/utils#readme) - library that has utilities functions
|
|
7
|
+
* [charts](https://github.com/RedHatInsights/frontend-components/tree/master/packages/charts#readme) - small group of general charts
|
|
8
|
+
* [components](https://github.com/RedHatInsights/frontend-components/tree/master/packages/components#readme) - series of common components
|
|
9
|
+
* [notifications](https://github.com/RedHatInsights/frontend-components/tree/master/packages/notifications#readme) - common component to display toast notifications
|
|
10
|
+
* [remediations](https://github.com/RedHatInsights/frontend-components/tree/master/packages/remediations#readme) - hot loaded component that shows remediations buton and wizard
|
|
11
|
+
* [inventory](https://github.com/RedHatInsights/insights-inventory-frontend) - Inventory packages moved to Inventory UI repository
|
|
12
|
+
* [sources](https://github.com/RedHatInsights/sources-ui/) - Sources Wizard component was moved to Sources UI repository (it's also stored here in `sources_backup` branch)
|
|
13
|
+
* [testing](https://github.com/RedHatInsights/frontend-components/tree/master/packages/testing) - Testing utilities.
|
|
14
|
+
* [advisor-components](https://github.com/RedHatInsights/frontend-components/tree/master/packages/advisor-components#readme) - a library of Advisor components (rule content, report details, charts, etc.).
|
|
9
15
|
|
|
10
|
-
**YARN**
|
|
11
|
-
```sh
|
|
12
|
-
$ yarn add -D @redhat-cloud-services/eslint-config-redhat-cloud-services
|
|
13
|
-
```
|
|
14
16
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
### Eslint
|
|
18
|
-
In your eslint configuration extends this eslint config
|
|
19
|
-
|
|
20
|
-
```JSON
|
|
21
|
-
{
|
|
22
|
-
"extends": "@redhat-cloud-services/eslint-config-redhat-cloud-services"
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
You can also extend multiple configurations and customize your rules
|
|
27
|
-
```JSON
|
|
28
|
-
{
|
|
29
|
-
"extends": ["@redhat-cloud-services/eslint-config-redhat-cloud-services", "other-config", ...],
|
|
30
|
-
"rules": {
|
|
31
|
-
"no-console": "warn"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Prettier
|
|
37
|
-
If you are not using prettier, firtst add `prettier.config.js`.
|
|
38
|
-
|
|
39
|
-
Add this content to your prettier configuration file:
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
module.exports = {
|
|
43
|
-
...require('@redhat-cloud-services/eslint-config-redhat-cloud-services/prettier.config.js'),
|
|
44
|
-
// For more configuration options visit: https://prettier.io/
|
|
45
|
-
};
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Used packages
|
|
49
|
-
- eslint-config-prettier
|
|
50
|
-
- eslint-plugin-prettier
|
|
51
|
-
- eslint-plugin-react
|
|
52
|
-
- prettier
|
|
17
|
+
## [Please read our contribution guide](./CONTRIBUTING.md)
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare let parser: string;
|
|
2
|
+
export declare namespace env {
|
|
3
|
+
let browser: boolean;
|
|
4
|
+
let node: boolean;
|
|
5
|
+
let es6: boolean;
|
|
6
|
+
let jasmine: boolean;
|
|
7
|
+
let jest: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace settings {
|
|
10
|
+
namespace react {
|
|
11
|
+
let version: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare let plugins: string[];
|
|
15
|
+
declare let _extends: string[];
|
|
16
|
+
export { _extends as extends };
|
|
17
|
+
export declare let rules: {
|
|
18
|
+
'no-unused-vars': (string | {
|
|
19
|
+
ignoreRestSiblings: boolean;
|
|
20
|
+
})[];
|
|
21
|
+
'prettier/prettier': (string | {
|
|
22
|
+
singleQuote: boolean;
|
|
23
|
+
})[];
|
|
24
|
+
'rulesdir/disallow-fec-relative-imports': number;
|
|
25
|
+
'rulesdir/deprecated-packages': number;
|
|
26
|
+
'rulesdir/no-chrome-api-call-from-window': number;
|
|
27
|
+
'rulesdir/forbid-pf-relative-imports': number;
|
|
28
|
+
'rulesdir/disallow-pf-migrated-components': number;
|
|
29
|
+
};
|
|
30
|
+
export declare namespace globals {
|
|
31
|
+
let CRC_APP_NAME: string;
|
|
32
|
+
}
|
|
33
|
+
export declare namespace parserOptions {
|
|
34
|
+
let ecmaVersion: number;
|
|
35
|
+
let sourceType: string;
|
|
36
|
+
}
|
package/index.js
CHANGED
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var rulesDirPlugin = require('eslint-plugin-rulesdir');
|
|
3
|
+
var path = require('path');
|
|
3
4
|
rulesDirPlugin.RULES_DIR = path.resolve(__dirname, './lib/rules');
|
|
4
|
-
|
|
5
5
|
module.exports = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
parser: '@babel/eslint-parser',
|
|
7
|
+
env: {
|
|
8
|
+
browser: true,
|
|
9
|
+
node: true,
|
|
10
|
+
es6: true,
|
|
11
|
+
jasmine: true,
|
|
12
|
+
jest: true,
|
|
13
|
+
},
|
|
14
|
+
settings: {
|
|
15
|
+
react: {
|
|
16
|
+
version: 'detect',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
plugins: ['prettier', 'rulesdir'],
|
|
20
|
+
extends: ['eslint:recommended', 'prettier', 'plugin:prettier/recommended', 'plugin:react/recommended'],
|
|
21
|
+
rules: {
|
|
22
|
+
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
|
|
23
|
+
'prettier/prettier': ['error', { singleQuote: true }],
|
|
24
|
+
'rulesdir/disallow-fec-relative-imports': 2,
|
|
25
|
+
'rulesdir/deprecated-packages': 1,
|
|
26
|
+
'rulesdir/no-chrome-api-call-from-window': 2,
|
|
27
|
+
'rulesdir/forbid-pf-relative-imports': 1,
|
|
28
|
+
'rulesdir/disallow-pf-migrated-components': 1,
|
|
29
|
+
},
|
|
30
|
+
globals: {
|
|
31
|
+
CRC_APP_NAME: 'readonly',
|
|
32
|
+
},
|
|
33
|
+
parserOptions: {
|
|
34
|
+
ecmaVersion: 7,
|
|
35
|
+
sourceType: 'module',
|
|
17
36
|
},
|
|
18
|
-
},
|
|
19
|
-
plugins: ['prettier', 'rulesdir'],
|
|
20
|
-
extends: ['eslint:recommended', 'prettier', 'plugin:prettier/recommended', 'plugin:react/recommended'],
|
|
21
|
-
rules: {
|
|
22
|
-
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
|
|
23
|
-
'prettier/prettier': ['error', { singleQuote: true }],
|
|
24
|
-
'rulesdir/disallow-fec-relative-imports': 2,
|
|
25
|
-
'rulesdir/deprecated-packages': 1,
|
|
26
|
-
'rulesdir/no-chrome-api-call-from-window': 2,
|
|
27
|
-
'rulesdir/forbid-pf-relative-imports': 1,
|
|
28
|
-
'rulesdir/disallow-pf-migrated-components': 1,
|
|
29
|
-
},
|
|
30
|
-
globals: {
|
|
31
|
-
CRC_APP_NAME: 'readonly',
|
|
32
|
-
},
|
|
33
|
-
parserOptions: {
|
|
34
|
-
ecmaVersion: 7,
|
|
35
|
-
sourceType: 'module',
|
|
36
|
-
},
|
|
37
37
|
};
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/eslint-config/index.js"],"names":[],"mappings":";AAAA,IAAM,cAAc,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACzD,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,cAAc,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAElE,MAAM,CAAC,OAAO,GAAG;IACf,MAAM,EAAE,sBAAsB;IAC9B,GAAG,EAAE;QACH,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,IAAI;QACV,GAAG,EAAE,IAAI;QACT,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,IAAI;KACX;IACD,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,OAAO,EAAE,QAAQ;SAClB;KACF;IACD,OAAO,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;IACjC,OAAO,EAAE,CAAC,oBAAoB,EAAE,UAAU,EAAE,6BAA6B,EAAE,0BAA0B,CAAC;IACtG,KAAK,EAAE;QACL,gBAAgB,EAAE,CAAC,OAAO,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC;QACzD,mBAAmB,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;QACrD,wCAAwC,EAAE,CAAC;QAC3C,8BAA8B,EAAE,CAAC;QACjC,yCAAyC,EAAE,CAAC;QAC5C,qCAAqC,EAAE,CAAC;QACxC,0CAA0C,EAAE,CAAC;KAC9C;IACD,OAAO,EAAE;QACP,YAAY,EAAE,UAAU;KACzB;IACD,aAAa,EAAE;QACb,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,QAAQ;KACrB;CACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export namespace meta {
|
|
2
|
+
let type: string;
|
|
3
|
+
namespace docs {
|
|
4
|
+
let description: string;
|
|
5
|
+
let category: string;
|
|
6
|
+
let recommended: boolean;
|
|
7
|
+
}
|
|
8
|
+
let fixable: string;
|
|
9
|
+
namespace messages {
|
|
10
|
+
let avoidUsingDeprecatedWithHint: string;
|
|
11
|
+
let avoidUsingDeprecated: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function create(context: any): {
|
|
15
|
+
ImportDeclaration: (codePath: any) => void;
|
|
16
|
+
};
|
|
@@ -1,43 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
10
12
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type: 'suggestion',
|
|
15
|
-
docs: {
|
|
16
|
-
description: 'disallow deprecated packages',
|
|
17
|
-
category: 'Possible run errors',
|
|
18
|
-
recommended: true,
|
|
13
|
+
var deprecatedPackages = {
|
|
14
|
+
'@redhat-cloud-services/frontend-components-pdf-generator': {
|
|
15
|
+
hint: 'https://github.com/RedHatInsights/pdf-generator',
|
|
19
16
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
};
|
|
18
|
+
module.exports = {
|
|
19
|
+
meta: {
|
|
20
|
+
type: 'suggestion',
|
|
21
|
+
docs: {
|
|
22
|
+
description: 'disallow deprecated packages',
|
|
23
|
+
category: 'Possible run errors',
|
|
24
|
+
recommended: true,
|
|
25
|
+
},
|
|
26
|
+
fixable: 'code',
|
|
27
|
+
messages: {
|
|
28
|
+
avoidUsingDeprecatedWithHint: 'Avoid using deprecated package {{ package }}. More info can be found at {{ hint }}.',
|
|
29
|
+
avoidUsingDeprecated: 'Avoid using deprecated package {{ package }}.',
|
|
30
|
+
},
|
|
24
31
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
create: function (context) {
|
|
33
|
+
return {
|
|
34
|
+
ImportDeclaration: function (codePath) {
|
|
35
|
+
var _a = Object.entries(deprecatedPackages).find(function (_a) {
|
|
36
|
+
var pckg = _a[0];
|
|
37
|
+
return codePath.source.value.includes(pckg);
|
|
38
|
+
}) || [], deprecatedImport = _a[0], data = _a[1];
|
|
39
|
+
if (deprecatedImport) {
|
|
40
|
+
context.report({
|
|
41
|
+
node: codePath,
|
|
42
|
+
messageId: data.hint ? 'avoidUsingDeprecatedWithHint' : 'avoidUsingDeprecated',
|
|
43
|
+
data: __assign({ package: codePath.source.value }, data),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
37
46
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
},
|
|
47
|
+
};
|
|
48
|
+
},
|
|
43
49
|
};
|
|
50
|
+
//# sourceMappingURL=deprecated-packages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecated-packages.js","sourceRoot":"","sources":["../../../../../packages/eslint-config/lib/rules/deprecated-packages.js"],"names":[],"mappings":";;;;;;;;;;;;AAKA,IAAM,kBAAkB,GAAG;IACzB,0DAA0D,EAAE;QAC1D,IAAI,EAAE,iDAAiD;KACxD;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,8BAA8B;YAC3C,QAAQ,EAAE,qBAAqB;YAC/B,WAAW,EAAE,IAAI;SAClB;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,4BAA4B,EAAE,qFAAqF;YACnH,oBAAoB,EAAE,+CAA+C;SACtE;KACF;IACD,MAAM,EAAE,UAAU,OAAO;QACvB,OAAO;YACL,iBAAiB,EAAE,UAAC,QAAQ;gBACpB,IAAA,KAA2B,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,UAAC,EAAM;wBAAL,IAAI,QAAA;oBAAM,OAAA,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAApC,CAAoC,CAAC,IAAI,EAAE,EAAzH,gBAAgB,QAAA,EAAE,IAAI,QAAmG,CAAC;gBACjI,IAAI,gBAAgB,EAAE,CAAC;oBACrB,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,QAAQ;wBACd,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,sBAAsB;wBAC9E,IAAI,aACF,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,IAC3B,IAAI,CACR;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export namespace meta {
|
|
2
|
+
let type: string;
|
|
3
|
+
namespace docs {
|
|
4
|
+
let description: string;
|
|
5
|
+
let category: string;
|
|
6
|
+
let recommended: boolean;
|
|
7
|
+
}
|
|
8
|
+
let fixable: string;
|
|
9
|
+
namespace messages {
|
|
10
|
+
let avoidRelativeImport: string;
|
|
11
|
+
let avoidImportingStyles: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function create(context: any): {
|
|
15
|
+
ImportDeclaration: (codePath: any) => void;
|
|
16
|
+
};
|
|
@@ -1,93 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'@redhat-cloud-services/frontend-components-remediations',
|
|
15
|
-
'@redhat-cloud-services/rule-components',
|
|
16
|
-
'@redhat-cloud-services/frontend-components-translations',
|
|
17
|
-
'@redhat-cloud-services/frontend-components-utilities',
|
|
1
|
+
"use strict";
|
|
2
|
+
var FECPackages = [
|
|
3
|
+
'@redhat-cloud-services/frontend-components-charts',
|
|
4
|
+
'@redhat-cloud-services/frontend-components',
|
|
5
|
+
'@redhat-cloud-services/frontend-components-config',
|
|
6
|
+
'@redhat-cloud-services/frontend-components-demo',
|
|
7
|
+
'@redhat-cloud-services/eslint-config-redhat-cloud-services',
|
|
8
|
+
'@redhat-cloud-services/frontend-components-notifications',
|
|
9
|
+
'@redhat-cloud-services/frontend-components-pdf-generator',
|
|
10
|
+
'@redhat-cloud-services/frontend-components-remediations',
|
|
11
|
+
'@redhat-cloud-services/rule-components',
|
|
12
|
+
'@redhat-cloud-services/frontend-components-translations',
|
|
13
|
+
'@redhat-cloud-services/frontend-components-utilities',
|
|
18
14
|
];
|
|
19
|
-
|
|
20
15
|
module.exports = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
meta: {
|
|
17
|
+
type: 'suggestion',
|
|
18
|
+
docs: {
|
|
19
|
+
description: 'disallow relative imports from FEC packages',
|
|
20
|
+
category: 'Possible build errors',
|
|
21
|
+
recommended: true,
|
|
22
|
+
},
|
|
23
|
+
fixable: 'code',
|
|
24
|
+
messages: {
|
|
25
|
+
avoidRelativeImport: 'Avoid using relative imports from {{ package }}. Use direct import path to {{ source }}. Module may be found at {{ hint }}.',
|
|
26
|
+
avoidImportingStyles: 'Avoid importing styles from {{ package }}. Styles are injected with components automatically.',
|
|
27
|
+
},
|
|
27
28
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
varName = variables[0].name;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
context.report({
|
|
75
|
-
node: codePath,
|
|
76
|
-
messageId: 'avoidRelativeImport',
|
|
77
|
-
data: {
|
|
78
|
-
package: importString,
|
|
79
|
-
source: varName,
|
|
80
|
-
hint: `import ${varName} from '${importString}/${varName}'`,
|
|
29
|
+
create: function (context) {
|
|
30
|
+
return {
|
|
31
|
+
ImportDeclaration: function (codePath) {
|
|
32
|
+
var importString = codePath.source.value;
|
|
33
|
+
var fecImport = FECPackages.find(function (pckg) { return importString.includes(pckg); });
|
|
34
|
+
if (fecImport && importString.match(/(css|scss|sass)/gim)) {
|
|
35
|
+
context.report({
|
|
36
|
+
node: codePath,
|
|
37
|
+
messageId: 'avoidImportingStyles',
|
|
38
|
+
data: {
|
|
39
|
+
package: importString,
|
|
40
|
+
},
|
|
41
|
+
fix: function (fixer) {
|
|
42
|
+
return fixer.remove(codePath.parent);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (fecImport && FECPackages.includes(importString)) {
|
|
47
|
+
var fullImport = context.getSourceCode(codePath.parent).text;
|
|
48
|
+
if (!fullImport.includes('from')) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
var variables_1 = context.getDeclaredVariables(codePath);
|
|
52
|
+
var varName = 'Unknown';
|
|
53
|
+
if (variables_1.length > 0) {
|
|
54
|
+
varName = variables_1[0].name;
|
|
55
|
+
}
|
|
56
|
+
context.report({
|
|
57
|
+
node: codePath,
|
|
58
|
+
messageId: 'avoidRelativeImport',
|
|
59
|
+
data: {
|
|
60
|
+
package: importString,
|
|
61
|
+
source: varName,
|
|
62
|
+
hint: "import ".concat(varName, " from '").concat(importString, "/").concat(varName, "'"),
|
|
63
|
+
},
|
|
64
|
+
fix: function (fixer) {
|
|
65
|
+
var newText = variables_1.map(function (data) {
|
|
66
|
+
return "import ".concat(data.name, " from \"").concat(importString, "/").concat(data.name, "\"");
|
|
67
|
+
});
|
|
68
|
+
return fixer.replaceText(codePath, newText.join('\n'));
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
81
72
|
},
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return `import ${data.name} from "${importString}/${data.name}"`;
|
|
85
|
-
});
|
|
86
|
-
return fixer.replaceText(codePath, newText.join('\n'));
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
},
|
|
73
|
+
};
|
|
74
|
+
},
|
|
93
75
|
};
|
|
76
|
+
//# sourceMappingURL=disallow-fec-relative-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disallow-fec-relative-imports.js","sourceRoot":"","sources":["../../../../../packages/eslint-config/lib/rules/disallow-fec-relative-imports.js"],"names":[],"mappings":";AAKA,IAAM,WAAW,GAAG;IAClB,mDAAmD;IACnD,4CAA4C;IAC5C,mDAAmD;IACnD,iDAAiD;IACjD,4DAA4D;IAC5D,0DAA0D;IAC1D,0DAA0D;IAC1D,yDAAyD;IACzD,wCAAwC;IACxC,yDAAyD;IACzD,sDAAsD;CACvD,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;YAC1D,QAAQ,EAAE,uBAAuB;YACjC,WAAW,EAAE,IAAI;SAClB;QACD,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,mBAAmB,EACjB,6HAA6H;YAC/H,oBAAoB,EAAE,+FAA+F;SACtH;KACF;IACD,MAAM,EAAE,UAAU,OAAO;QACvB,OAAO;YACL,iBAAiB,EAAE,UAAU,QAAQ;gBACnC,IAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC3C,IAAM,SAAS,GAAG,WAA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AAO,GAAG,WAAS,CAAC,GAAG,CAAC,UAAU,IAAI;gCAC1C,OAAO,iBAAU,IAAI,CAAC,IAAI,qBAAU,YAAY,cAAI,IAAI,CAAC,IAAI,OAAG,CAAC;4BACnE,CAAC,CAAC,CAAC;4BACH,OAAO,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBACzD,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export namespace meta {
|
|
2
|
+
let type: string;
|
|
3
|
+
namespace docs {
|
|
4
|
+
let description: string;
|
|
5
|
+
let category: string;
|
|
6
|
+
let recommended: boolean;
|
|
7
|
+
}
|
|
8
|
+
let fixable: string;
|
|
9
|
+
let schema: never[];
|
|
10
|
+
}
|
|
11
|
+
export function create(context: any): {
|
|
12
|
+
ImportDeclaration(node: any): void;
|
|
13
|
+
};
|
|
@@ -1,52 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @author Filip Hlavac
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// Please add any components moved to the @patternfly/react-component-groups repo from this one
|
|
7
|
-
const forbiddenImports = ['ErrorBoundary', 'ErrorState', 'NotAuthorized'];
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var forbiddenImports = ['ErrorBoundary', 'ErrorState', 'NotAuthorized'];
|
|
9
3
|
module.exports = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
meta: {
|
|
5
|
+
type: 'suggestion',
|
|
6
|
+
docs: {
|
|
7
|
+
description: 'disallow already migrated components',
|
|
8
|
+
category: 'Possible run errors',
|
|
9
|
+
recommended: true,
|
|
10
|
+
},
|
|
11
|
+
fixable: 'code',
|
|
12
|
+
schema: [],
|
|
13
|
+
},
|
|
14
|
+
create: function (context) {
|
|
15
|
+
return {
|
|
16
|
+
ImportDeclaration: function (node) {
|
|
17
|
+
var sourceValue = node.source.value;
|
|
18
|
+
var specifiers = node.specifiers;
|
|
19
|
+
var patternflyPackage = '@patternfly/react-component-groups';
|
|
20
|
+
if (sourceValue === '@redhat-cloud-services/frontend-components') {
|
|
21
|
+
specifiers.forEach(function (specifier) {
|
|
22
|
+
if (specifier.type === 'ImportDefaultSpecifier' && forbiddenImports.includes(specifier.local.name)) {
|
|
23
|
+
context.report({
|
|
24
|
+
node: node,
|
|
25
|
+
message: "Importing ".concat(specifier.local.name, " from ").concat(sourceValue, " is deprecated, use import from ").concat(patternflyPackage, " instead."),
|
|
26
|
+
fix: function (fixer) {
|
|
27
|
+
var importStatement = "import ".concat(specifier.local.name, " from '").concat(patternflyPackage, "';");
|
|
28
|
+
return fixer.replaceText(node, importStatement);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else if (specifier.type === 'ImportSpecifier' && forbiddenImports.includes(specifier.imported.name)) {
|
|
33
|
+
context.report({
|
|
34
|
+
node: node,
|
|
35
|
+
message: "Importing ".concat(specifier.imported.name, " from ").concat(sourceValue, " is deprecated, use import from ").concat(patternflyPackage, " instead."),
|
|
36
|
+
fix: function (fixer) {
|
|
37
|
+
var importStatement = "import { ".concat(specifier.imported.name, " } from '").concat(patternflyPackage, "';");
|
|
38
|
+
return fixer.replaceText(node, importStatement);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
16
46
|
},
|
|
17
|
-
fixable: 'code',
|
|
18
|
-
schema: [],
|
|
19
|
-
},
|
|
20
|
-
create: function (context) {
|
|
21
|
-
return {
|
|
22
|
-
ImportDeclaration(node) {
|
|
23
|
-
const sourceValue = node.source.value;
|
|
24
|
-
const specifiers = node.specifiers;
|
|
25
|
-
const patternflyPackage = '@patternfly/react-component-groups';
|
|
26
|
-
if (sourceValue === '@redhat-cloud-services/frontend-components') {
|
|
27
|
-
specifiers.forEach((specifier) => {
|
|
28
|
-
if (specifier.type === 'ImportDefaultSpecifier' && forbiddenImports.includes(specifier.local.name)) {
|
|
29
|
-
context.report({
|
|
30
|
-
node,
|
|
31
|
-
message: `Importing ${specifier.local.name} from ${sourceValue} is deprecated, use import from ${patternflyPackage} instead.`,
|
|
32
|
-
fix(fixer) {
|
|
33
|
-
const importStatement = `import ${specifier.local.name} from '${patternflyPackage}';`;
|
|
34
|
-
return fixer.replaceText(node, importStatement);
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
} else if (specifier.type === 'ImportSpecifier' && forbiddenImports.includes(specifier.imported.name)) {
|
|
38
|
-
context.report({
|
|
39
|
-
node,
|
|
40
|
-
message: `Importing ${specifier.imported.name} from ${sourceValue} is deprecated, use import from ${patternflyPackage} instead.`,
|
|
41
|
-
fix(fixer) {
|
|
42
|
-
const importStatement = `import { ${specifier.imported.name} } from '${patternflyPackage}';`;
|
|
43
|
-
return fixer.replaceText(node, importStatement);
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
47
|
};
|
|
48
|
+
//# sourceMappingURL=disallow-pf-migrated-components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disallow-pf-migrated-components.js","sourceRoot":"","sources":["../../../../../packages/eslint-config/lib/rules/disallow-pf-migrated-components.js"],"names":[],"mappings":";AAMA,IAAM,gBAAgB,GAAG,CAAC,eAAe,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;AAE1E,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,qBAAqB;YAC/B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AC,IAAI,sBAAY,iBAAiB,OAAI,CAAC;oCAC7F,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;gCAClD,CAAC;6BACF,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export namespace meta {
|
|
2
|
+
let type: string;
|
|
3
|
+
namespace docs {
|
|
4
|
+
let description: string;
|
|
5
|
+
let category: string;
|
|
6
|
+
let recommended: boolean;
|
|
7
|
+
}
|
|
8
|
+
let fixable: string;
|
|
9
|
+
namespace messages {
|
|
10
|
+
let avoidRelativeImport: string;
|
|
11
|
+
let avoidRelativeIconImport: string;
|
|
12
|
+
let avoidImportingStyles: string;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function create(context: any): {
|
|
16
|
+
ImportDeclaration: (codePath: any) => void;
|
|
17
|
+
};
|
|
@@ -1,194 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const ICONS_NAME_FIX = {
|
|
14
|
-
AnsibeTowerIcon: 'ansibeTower-icon',
|
|
15
|
-
ChartSpikeIcon: 'chartSpike-icon',
|
|
16
|
-
CloudServerIcon: 'cloudServer-icon',
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
17
12
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
var glob = require('glob');
|
|
14
|
+
var path = require('path');
|
|
15
|
+
var PFPackages = ['@patternfly/react-core', '@patternfly/react-icons', '@patternfly/tokens'];
|
|
16
|
+
var PROPS_MATCH = /Props$/g;
|
|
17
|
+
var VARIANT_MATCH = /Variants?$/g;
|
|
18
|
+
var POSITION_MATCH = /Position$/g;
|
|
19
|
+
var ICONS_NAME_FIX = {
|
|
20
|
+
AnsibeTowerIcon: 'ansibeTower-icon',
|
|
21
|
+
ChartSpikeIcon: 'chartSpike-icon',
|
|
22
|
+
CloudServerIcon: 'cloudServer-icon',
|
|
23
|
+
};
|
|
24
|
+
var CORE_CACHE = {};
|
|
25
|
+
var COMPONENTS_CACHE = {};
|
|
22
26
|
function findCoreComponent(name) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
source
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
source
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
source
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
27
|
+
var _a, _b, _c, _d;
|
|
28
|
+
if (CORE_CACHE[name]) {
|
|
29
|
+
return CORE_CACHE[name];
|
|
30
|
+
}
|
|
31
|
+
var source = (_a = glob
|
|
32
|
+
.sync(path.resolve(process.cwd(), "node_modules/".concat(PFPackages[0], "/dist/esm/**/").concat(name, ".js")))
|
|
33
|
+
.filter(function (path) { return !path.includes('deprecated'); })) === null || _a === void 0 ? void 0 : _a[0];
|
|
34
|
+
if (!source && name.match(PROPS_MATCH)) {
|
|
35
|
+
source = (_b = glob
|
|
36
|
+
.sync(path.resolve(process.cwd(), "node_modules/".concat(PFPackages[0], "/dist/esm/**/").concat(name.replace(PROPS_MATCH, ''), ".js")))
|
|
37
|
+
.filter(function (path) { return !path.includes('deprecated'); })) === null || _b === void 0 ? void 0 : _b[0];
|
|
38
|
+
}
|
|
39
|
+
if (!source && name.match(VARIANT_MATCH)) {
|
|
40
|
+
source = (_c = glob
|
|
41
|
+
.sync(path.resolve(process.cwd(), "node_modules/".concat(PFPackages[0], "/dist/esm/**/").concat(name.replace(VARIANT_MATCH, ''), ".js")))
|
|
42
|
+
.filter(function (path) { return !path.includes('deprecated'); })) === null || _c === void 0 ? void 0 : _c[0];
|
|
43
|
+
}
|
|
44
|
+
if (!source && name.match(POSITION_MATCH)) {
|
|
45
|
+
source = (_d = glob
|
|
46
|
+
.sync(path.resolve(process.cwd(), "node_modules/".concat(PFPackages[0], "/dist/esm/**/").concat(name.replace(POSITION_MATCH, ''), ".js")))
|
|
47
|
+
.filter(function (path) { return !path.includes('deprecated'); })) === null || _d === void 0 ? void 0 : _d[0];
|
|
48
|
+
}
|
|
49
|
+
if (!source) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
var dynamicSource = source.split('node_modules/').pop().replace('/esm/', '/dynamic/').split('/');
|
|
53
|
+
dynamicSource.pop();
|
|
54
|
+
dynamicSource = dynamicSource.join('/');
|
|
55
|
+
CORE_CACHE[name] = dynamicSource;
|
|
56
|
+
return dynamicSource;
|
|
52
57
|
}
|
|
53
|
-
|
|
54
58
|
function camelToDash(str) {
|
|
55
|
-
|
|
59
|
+
return str.replace(/([A-Z])/g, function (g) { return "-".concat(g[0].toLowerCase()); }).replace(/^-/, '');
|
|
56
60
|
}
|
|
57
|
-
|
|
58
61
|
function findIcon(name) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
if (COMPONENTS_CACHE[name]) {
|
|
63
|
+
return COMPONENTS_CACHE[name];
|
|
64
|
+
}
|
|
65
|
+
var nameSpecifier = ICONS_NAME_FIX[name] || camelToDash(name);
|
|
66
|
+
return "@patternfly/react-icons/dist/dynamic/icons/".concat(nameSpecifier);
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
CORE_CACHE = {
|
|
67
|
-
...CORE_CACHE,
|
|
68
|
-
getResizeObserver: findCoreComponent('resizeObserver'),
|
|
69
|
-
useOUIAProps: findCoreComponent('ouia'),
|
|
70
|
-
OUIAProps: findCoreComponent('ouia'),
|
|
71
|
-
getDefaultOUIAId: findCoreComponent('ouia'),
|
|
72
|
-
useOUIAId: findCoreComponent('ouia'),
|
|
73
|
-
handleArrows: findCoreComponent('KeyboardHandler'),
|
|
74
|
-
setTabIndex: findCoreComponent('KeyboardHandler'),
|
|
75
|
-
IconComponentProps: findCoreComponent('Icon'),
|
|
76
|
-
TreeViewDataItem: findCoreComponent('TreeView'),
|
|
77
|
-
Popper: findCoreComponent('Popper/Popper'),
|
|
78
|
-
};
|
|
79
|
-
|
|
68
|
+
CORE_CACHE = __assign(__assign({}, CORE_CACHE), { getResizeObserver: findCoreComponent('resizeObserver'), useOUIAProps: findCoreComponent('ouia'), OUIAProps: findCoreComponent('ouia'), getDefaultOUIAId: findCoreComponent('ouia'), useOUIAId: findCoreComponent('ouia'), handleArrows: findCoreComponent('KeyboardHandler'), setTabIndex: findCoreComponent('KeyboardHandler'), IconComponentProps: findCoreComponent('Icon'), TreeViewDataItem: findCoreComponent('TreeView'), Popper: findCoreComponent('Popper/Popper') });
|
|
80
69
|
module.exports = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
meta: {
|
|
71
|
+
type: 'suggestion',
|
|
72
|
+
docs: {
|
|
73
|
+
description: 'forbid relative imports from PF packages',
|
|
74
|
+
category: 'Possible build errors',
|
|
75
|
+
recommended: true,
|
|
76
|
+
},
|
|
77
|
+
fixable: 'code',
|
|
78
|
+
messages: {
|
|
79
|
+
avoidRelativeImport: 'Avoid using relative imports from {{ package }}. Use direct import path to {{ source }}. Module may be found at {{ hint }}.',
|
|
80
|
+
avoidRelativeIconImport: 'Avoid using relative imports from {{ package }}. Use direct import path to {{ source }}. Module may be found at {{ hint }}.',
|
|
81
|
+
avoidImportingStyles: 'Avoid importing styles from {{ package }}. Styles are injected with components automatically.',
|
|
82
|
+
},
|
|
87
83
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
84
|
+
create: function (context) {
|
|
85
|
+
return {
|
|
86
|
+
ImportDeclaration: function (codePath) {
|
|
87
|
+
var importString = codePath.source.value;
|
|
88
|
+
var pfImport = importString === PFPackages[0];
|
|
89
|
+
var iconsImport = importString === PFPackages[1];
|
|
90
|
+
if (PFPackages.includes(importString) && importString.match(/(css|scss|sass)/gim)) {
|
|
91
|
+
context.report({
|
|
92
|
+
node: codePath,
|
|
93
|
+
messageId: 'avoidImportingStyles',
|
|
94
|
+
data: {
|
|
95
|
+
package: importString,
|
|
96
|
+
},
|
|
97
|
+
fix: function (fixer) {
|
|
98
|
+
return fixer.remove(codePath.parent);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (pfImport && PFPackages.includes(importString)) {
|
|
103
|
+
var fullImport = context.getSourceCode(codePath.parent).text;
|
|
104
|
+
if (!fullImport.includes('from')) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
var variables = context.getDeclaredVariables(codePath);
|
|
108
|
+
var varName = 'Unknown';
|
|
109
|
+
if (variables.length > 0) {
|
|
110
|
+
varName = variables[0].name;
|
|
111
|
+
}
|
|
112
|
+
var newText_1 = variables.map(function (data) {
|
|
113
|
+
var importPartial = findCoreComponent(data.name);
|
|
114
|
+
return "import { ".concat(data.name, " } from '").concat(importPartial, "'");
|
|
115
|
+
});
|
|
116
|
+
context.report({
|
|
117
|
+
node: codePath,
|
|
118
|
+
messageId: 'avoidRelativeImport',
|
|
119
|
+
data: {
|
|
120
|
+
package: importString,
|
|
121
|
+
source: varName,
|
|
122
|
+
hint: newText_1.join('\n'),
|
|
123
|
+
},
|
|
124
|
+
fix: function (fixer) {
|
|
125
|
+
return fixer.replaceText(codePath, newText_1.join('\n'));
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (iconsImport) {
|
|
130
|
+
var fullImport = context.getSourceCode(codePath.parent).text;
|
|
131
|
+
if (!fullImport.includes('from')) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
var variables = context.getDeclaredVariables(codePath);
|
|
135
|
+
var varName = 'Unknown';
|
|
136
|
+
if (variables.length > 0) {
|
|
137
|
+
varName = variables[0].name;
|
|
138
|
+
}
|
|
139
|
+
var newText_2 = variables.map(function (data) {
|
|
140
|
+
var importPartial = findIcon(data.name);
|
|
141
|
+
return "import ".concat(data.name, " from '").concat(importPartial, "'");
|
|
142
|
+
});
|
|
143
|
+
context.report({
|
|
144
|
+
node: codePath,
|
|
145
|
+
messageId: 'avoidRelativeIconImport',
|
|
146
|
+
data: {
|
|
147
|
+
package: importString,
|
|
148
|
+
source: varName,
|
|
149
|
+
hint: newText_2.join('\n'),
|
|
150
|
+
},
|
|
151
|
+
fix: function (fixer) {
|
|
152
|
+
return fixer.replaceText(codePath, newText_2.join('\n'));
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
148
156
|
},
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Check icons import
|
|
157
|
-
*/
|
|
158
|
-
if (iconsImport) {
|
|
159
|
-
const fullImport = context.getSourceCode(codePath.parent).text;
|
|
160
|
-
/**
|
|
161
|
-
* Check if the import is not full import statement
|
|
162
|
-
*/
|
|
163
|
-
if (!fullImport.includes('from')) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let variables = context.getDeclaredVariables(codePath);
|
|
168
|
-
let varName = 'Unknown';
|
|
169
|
-
if (variables.length > 0) {
|
|
170
|
-
varName = variables[0].name;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const newText = variables.map(function (data) {
|
|
174
|
-
const importPartial = findIcon(data.name);
|
|
175
|
-
return `import ${data.name} from '${importPartial}'`;
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
context.report({
|
|
179
|
-
node: codePath,
|
|
180
|
-
messageId: 'avoidRelativeIconImport',
|
|
181
|
-
data: {
|
|
182
|
-
package: importString,
|
|
183
|
-
source: varName,
|
|
184
|
-
hint: newText.join('\n'),
|
|
185
|
-
},
|
|
186
|
-
fix: function (fixer) {
|
|
187
|
-
return fixer.replaceText(codePath, newText.join('\n'));
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
},
|
|
157
|
+
};
|
|
158
|
+
},
|
|
194
159
|
};
|
|
160
|
+
//# sourceMappingURL=forbid-pf-relative-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forbid-pf-relative-imports.js","sourceRoot":"","sources":["../../../../../packages/eslint-config/lib/rules/forbid-pf-relative-imports.js"],"names":[],"mappings":";;;;;;;;;;;;AAIA,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,IAAM,UAAU,GAAG,CAAC,wBAAwB,EAAE,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;AAE/F,IAAM,WAAW,GAAG,SAAS,CAAC;AAC9B,IAAM,aAAa,GAAG,aAAa,CAAC;AACpC,IAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,IAAM,cAAc,GAAG;IACrB,eAAe,EAAE,kBAAkB;IACnC,cAAc,EAAE,iBAAiB;IACjC,eAAe,EAAE,kBAAkB;CACpC,CAAC;AAEF,IAAI,UAAU,GAAG,EAAE,CAAC;AACpB,IAAI,gBAAgB,GAAG,EAAE,CAAC;AAE1B,SAAS,iBAAiB,CAAC,IAAI;;IAC7B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IACD,IAAI,MAAM,GAAG,MAAA,IAAI;SACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,uBAAgB,UAAU,CAAC,CAAC,CAAC,0BAAgB,IAAI,QAAK,CAAC,CAAC;SACzF,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAA5B,CAA4B,CAAC,0CAAG,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM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AAM,CAAC,EAAE,CAAC;wBACjC,OAAO;oBACT,CAAC;oBAED,IAAI,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;oBACvD,IAAI,OAAO,GAAG,SAAS,CAAC;oBACxB,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACzB,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;oBAC9B,CAAC;oBAED,IAAM,SAAO,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,IAAI;wBAC1C,IAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAC1C,OAAO,iBAAU,IAAI,CAAC,IAAI,oBAAU,aAAa,MAAG,CAAC;oBACvD,CAAC,CAAC,CAAC;oBAEH,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,QAAQ;wBACd,SAAS,EAAE,yBAAyB;wBACpC,IAAI,EAAE;4BACJ,OAAO,EAAE,YAAY;4BACrB,MAAM,EAAE,OAAO;4BACf,IAAI,EAAE,SAAO,CAAC,IAAI,CAAC,IAAI,CAAC;yBACzB;wBACD,GAAG,EAAE,UAAU,KAAK;4BAClB,OAAO,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;wBACzD,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export namespace meta {
|
|
2
|
+
let type: string;
|
|
3
|
+
let fixable: string;
|
|
4
|
+
namespace messages {
|
|
5
|
+
let useSharedAxiosMessage: string;
|
|
6
|
+
}
|
|
7
|
+
namespace docs {
|
|
8
|
+
let description: string;
|
|
9
|
+
let url: string;
|
|
10
|
+
let recommended: boolean;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function create(context: any): {
|
|
14
|
+
ImportDeclaration: (codePath: any) => void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
meta: {
|
|
4
|
+
type: 'suggestion',
|
|
5
|
+
fixable: 'code',
|
|
6
|
+
messages: {
|
|
7
|
+
useSharedAxiosMessage: 'Avoid using axios in your project. Instead, use the shared axios instance with interceptors for better error handling and reporting',
|
|
8
|
+
},
|
|
9
|
+
docs: {
|
|
10
|
+
description: 'Use the shared axios instance',
|
|
11
|
+
url: 'https://github.com/RedHatInsights/frontend-components/blob/master/packages/utils/src/interceptors/interceptors.ts#L83',
|
|
12
|
+
recommended: false,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
create: function (context) {
|
|
16
|
+
return {
|
|
17
|
+
ImportDeclaration: function (codePath) {
|
|
18
|
+
if (codePath.source.value.includes('axios')) {
|
|
19
|
+
context.report({
|
|
20
|
+
node: codePath,
|
|
21
|
+
messageId: 'useSharedAxiosMessage',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=insights-disallow-custom-axios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insights-disallow-custom-axios.js","sourceRoot":"","sources":["../../../../../packages/eslint-config/lib/rules/insights-disallow-custom-axios.js"],"names":[],"mappings":";AAKA,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE;YACR,qBAAqB,EACnB,qIAAqI;SACxI;QACD,IAAI,EAAE;YACJ,WAAW,EAAE,+BAA+B;YAC5C,GAAG,EAAE,uHAAuH;YAC5H,WAAW,EAAE,KAAK;SACnB;KACF;IACD,MAAM,EAAE,UAAU,OAAO;QACvB,OAAO;YACL,iBAAiB,EAAE,UAAC,QAAQ;gBAC1B,IAAI,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC5C,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,QAAQ;wBACd,SAAS,EAAE,uBAAuB;qBACnC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
meta: {
|
|
4
|
+
type: 'suggestion',
|
|
5
|
+
messages: {
|
|
6
|
+
deprecateChromeApiCallFromWindow: 'Calling chrome API from the window object is deprecated.',
|
|
7
|
+
},
|
|
8
|
+
fixable: 'code',
|
|
9
|
+
schema: [],
|
|
10
|
+
},
|
|
11
|
+
create: function (context) {
|
|
12
|
+
return {
|
|
13
|
+
Identifier: function (node) {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
|
+
if ((node === null || node === void 0 ? void 0 : node.name) === 'window' && ((_b = (_a = node === null || node === void 0 ? void 0 : node.parent) === null || _a === void 0 ? void 0 : _a.property) === null || _b === void 0 ? void 0 : _b.name) === 'insights' && ((_e = (_d = (_c = node === null || node === void 0 ? void 0 : node.parent) === null || _c === void 0 ? void 0 : _c.parent) === null || _d === void 0 ? void 0 : _d.property) === null || _e === void 0 ? void 0 : _e.name) === 'chrome') {
|
|
16
|
+
context.report({ node: node, messageId: 'deprecateChromeApiCallFromWindow' });
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
};
|
|
6
20
|
},
|
|
7
|
-
fixable: 'code',
|
|
8
|
-
schema: [],
|
|
9
|
-
},
|
|
10
|
-
create: function (context) {
|
|
11
|
-
return {
|
|
12
|
-
Identifier(node) {
|
|
13
|
-
if (node?.name === 'window' && node?.parent?.property?.name === 'insights' && node?.parent?.parent?.property?.name === 'chrome') {
|
|
14
|
-
context.report({ node, messageId: 'deprecateChromeApiCallFromWindow' });
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
},
|
|
19
21
|
};
|
|
22
|
+
//# sourceMappingURL=no-chrome-api-call-from-window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-chrome-api-call-from-window.js","sourceRoot":"","sources":["../../../../../packages/eslint-config/lib/rules/no-chrome-api-call-from-window.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE;YACR,gCAAgC,EAAE,0DAA0D;SAC7F;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;KACX;IACD,MAAM,EAAE,UAAU,OAAO;QACvB,OAAO;YACL,UAAU,YAAC,IAAI;;gBACb,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,QAAQ,IAAI,CAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,0CAAE,QAAQ,0CAAE,IAAI,MAAK,UAAU,IAAI,CAAA,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,0CAAE,MAAM,0CAAE,QAAQ,0CAAE,IAAI,MAAK,QAAQ,EAAE,CAAC;oBAChI,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,MAAA,EAAE,SAAS,EAAE,kCAAkC,EAAE,CAAC,CAAC;gBAC1E,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
2
|
+
"name": "@redhat-cloud-services/eslint-config-redhat-cloud-services",
|
|
3
|
+
"version": "2.0.6",
|
|
4
|
+
"description": "Recommended eslint configuration used in cloud.redhat.com frontend apps.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eslint",
|
|
7
|
+
"eslintplugin",
|
|
8
|
+
"eslint-plugin"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
13
|
+
"eslint-config-prettier": "^8.5.0",
|
|
14
|
+
"eslint-plugin-prettier": "^3.4.1",
|
|
15
|
+
"eslint-plugin-react": "^7.31.8",
|
|
16
|
+
"eslint-plugin-rulesdir": "^0.2.1",
|
|
17
|
+
"prettier": "^2.7.1"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@babel/core": "^7.14.0",
|
|
21
|
+
"eslint": "^8.9.0"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"main": "./index.js",
|
|
28
|
+
"type": "commonjs",
|
|
29
|
+
"types": "./index.d.ts"
|
|
30
|
+
}
|