@redhat-cloud-services/eslint-config-redhat-cloud-services 1.2.5 → 1.3.0

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/index.js CHANGED
@@ -17,11 +17,13 @@ module.exports = {
17
17
  },
18
18
  },
19
19
  plugins: ['prettier', 'rulesdir'],
20
- extends: ['eslint:recommended', 'prettier', 'plugin:prettier/recommended', 'plugin:react/recommended', 'plugin:cypress/recommended'],
20
+ extends: ['eslint:recommended', 'prettier', 'plugin:prettier/recommended', 'plugin:react/recommended'],
21
21
  rules: {
22
22
  'no-unused-vars': ['error', { ignoreRestSiblings: true }],
23
23
  'prettier/prettier': ['error', { singleQuote: true }],
24
24
  'rulesdir/disallow-fec-relative-imports': 2,
25
+ 'rulesdir/deprecated-packages': 1,
26
+ 'rulesdir/no-chrome-api-call-from-window': 2,
25
27
  },
26
28
  globals: {
27
29
  CRC_APP_NAME: 'readonly',
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @fileoverview Rule to warn about deprecated packages.
3
+ * @author Karel Hala
4
+ */
5
+
6
+ const deprecatedPackages = {
7
+ '@redhat-cloud-services/frontend-components-pdf-generator': {
8
+ hint: 'https://github.com/RedHatInsights/pdf-generator',
9
+ },
10
+ };
11
+
12
+ module.exports = {
13
+ meta: {
14
+ type: 'suggestion',
15
+ docs: {
16
+ description: 'disallow deprecated packages',
17
+ category: 'Possible run errors',
18
+ recommended: true,
19
+ },
20
+ fixable: 'code',
21
+ messages: {
22
+ avoidUsingDeprecatedWithHint: 'Avoid using deprecated package {{ package }}. More info can be found at {{ hint }}.',
23
+ avoidUsingDeprecated: 'Avoid using deprecated package {{ package }}.',
24
+ },
25
+ },
26
+ create: function (context) {
27
+ return {
28
+ ImportDeclaration: (codePath) => {
29
+ const [deprecatedImport, data] = Object.entries(deprecatedPackages).find(([pckg]) => codePath.source.value.includes(pckg)) || [];
30
+ if (deprecatedImport) {
31
+ context.report({
32
+ node: codePath,
33
+ messageId: data.hint ? 'avoidUsingDeprecatedWithHint' : 'avoidUsingDeprecated',
34
+ data: {
35
+ package: codePath.source.value,
36
+ ...data,
37
+ },
38
+ });
39
+ }
40
+ },
41
+ };
42
+ },
43
+ };
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ meta: {
3
+ type: 'suggestion',
4
+ messages: {
5
+ deprecateChromeApiCallFromWindow: 'Calling chrome API from the window object is deprecated.',
6
+ },
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redhat-cloud-services/eslint-config-redhat-cloud-services",
3
- "version": "1.2.5",
3
+ "version": "1.3.0",
4
4
  "description": "Recommended eslint configuration used in cloud.redhat.com frontend apps.",
5
5
  "keywords": [
6
6
  "eslint",