@akinon/eslint-plugin-projectzero 1.43.0-rc.6 → 1.43.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/CHANGELOG.md CHANGED
@@ -1,33 +1,6 @@
1
1
  # @akinon/eslint-plugin-projectzero
2
2
 
3
- ## 1.43.0-rc.6
4
-
5
- ### Minor Changes
6
-
7
- - 5a4c607: ZERO-2764: Add case-warning rule to eslint-plugin-projectzero
8
- - 64699d3: ZERO-2761: Fix invalid import for plugin module
9
- - c474780: ZERO-2666: Add rule to check menu depth
10
-
11
- ## 1.43.0-rc.5
12
-
13
- ## 1.43.0-rc.4
14
-
15
- ## 1.43.0-rc.3
16
-
17
- ### Minor Changes
18
-
19
- - 64699d3: ZERO-2761: Fix invalid import for plugin module
20
-
21
- ## 1.43.0-rc.2
22
-
23
- ## 1.43.0-rc.1
24
-
25
- ## 1.43.0-rc.0
26
-
27
- ### Minor Changes
28
-
29
- - 5a4c607: ZERO-2764: Add case-warning rule to eslint-plugin-projectzero
30
- - c474780: ZERO-2666: Add rule to check menu depth
3
+ ## 1.43.0
31
4
 
32
5
  ## 1.42.0
33
6
 
package/configs/core.ts CHANGED
@@ -9,8 +9,6 @@ export default {
9
9
  '@akinon/projectzero/meta-data-import': 'error',
10
10
  '@akinon/projectzero/urls-without-slash': 'error',
11
11
  '@akinon/projectzero/invalid-imports': 'error',
12
- '@akinon/projectzero/check-menu-depth': 'error',
13
- '@akinon/projectzero/case-warning': 'warn',
14
12
  'no-restricted-syntax': [
15
13
  'error',
16
14
  {
@@ -1,25 +1,22 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
- rules: {
5
- '@akinon/projectzero/image-import': 'error',
6
- '@akinon/projectzero/client-url': 'error',
7
- '@akinon/projectzero/link-import': 'error',
8
- '@akinon/projectzero/router-import': 'error',
9
- '@akinon/projectzero/skip-trailing-slash-redirect': 'error',
10
- '@akinon/projectzero/check-locale': 'error',
11
- '@akinon/projectzero/meta-data-import': 'error',
12
- '@akinon/projectzero/urls-without-slash': 'error',
13
- '@akinon/projectzero/invalid-imports': 'error',
14
- '@akinon/projectzero/check-menu-depth': 'error',
15
- '@akinon/projectzero/case-warning': 'warn',
16
- 'no-restricted-syntax': [
17
- 'error',
18
- {
19
- selector:
20
- "MemberExpression[property.name='COMMERCE_URL'][object.property.name='env'][object.object.name='process']",
21
- message: "You should use it as 'Settings.commerceUrl'"
22
- }
23
- ]
24
- }
4
+ rules: {
5
+ '@akinon/projectzero/image-import': 'error',
6
+ '@akinon/projectzero/client-url': 'error',
7
+ '@akinon/projectzero/link-import': 'error',
8
+ '@akinon/projectzero/router-import': 'error',
9
+ '@akinon/projectzero/skip-trailing-slash-redirect': 'error',
10
+ '@akinon/projectzero/check-locale': 'error',
11
+ '@akinon/projectzero/meta-data-import': 'error',
12
+ '@akinon/projectzero/urls-without-slash': 'error',
13
+ '@akinon/projectzero/invalid-imports': 'error',
14
+ 'no-restricted-syntax': [
15
+ 'error',
16
+ {
17
+ selector: "MemberExpression[property.name='COMMERCE_URL'][object.property.name='env'][object.object.name='process']",
18
+ message: "You should use it as 'Settings.commerceUrl'"
19
+ }
20
+ ]
21
+ }
25
22
  };
@@ -1,39 +1,29 @@
1
- 'use strict';
2
- var __importDefault =
3
- (this && this.__importDefault) ||
4
- function (mod) {
5
- return mod && mod.__esModule ? mod : { default: mod };
6
- };
7
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
8
6
  exports.rules = void 0;
9
- const client_url_1 = __importDefault(require('./client-url'));
10
- const image_import_1 = __importDefault(require('./image-import'));
11
- const link_import_1 = __importDefault(require('./link-import'));
12
- const router_import_1 = __importDefault(require('./router-import'));
13
- const skip_trailing_slash_redirect_1 = __importDefault(
14
- require('./skip-trailing-slash-redirect')
15
- );
16
- const check_locale_1 = __importDefault(require('./check-locale'));
17
- const meta_data_import_1 = __importDefault(require('./meta-data-import'));
18
- const check_middleware_order_1 = __importDefault(
19
- require('./check-middleware-order')
20
- );
21
- const urls_without_slash_1 = __importDefault(require('./urls-without-slash'));
22
- const invalid_imports_1 = __importDefault(require('./invalid-imports'));
23
- const check_menu_depth_1 = __importDefault(require('./check-menu-depth'));
24
- const case_warning_1 = __importDefault(require('./case-warning'));
7
+ const client_url_1 = __importDefault(require("./client-url"));
8
+ const image_import_1 = __importDefault(require("./image-import"));
9
+ const link_import_1 = __importDefault(require("./link-import"));
10
+ const router_import_1 = __importDefault(require("./router-import"));
11
+ const skip_trailing_slash_redirect_1 = __importDefault(require("./skip-trailing-slash-redirect"));
12
+ const check_locale_1 = __importDefault(require("./check-locale"));
13
+ const meta_data_import_1 = __importDefault(require("./meta-data-import"));
14
+ const check_middleware_order_1 = __importDefault(require("./check-middleware-order"));
15
+ const urls_without_slash_1 = __importDefault(require("./urls-without-slash"));
16
+ const invalid_imports_1 = __importDefault(require("./invalid-imports"));
25
17
  const rules = {
26
- 'client-url': client_url_1.default,
27
- 'image-import': image_import_1.default,
28
- 'link-import': link_import_1.default,
29
- 'router-import': router_import_1.default,
30
- 'skip-trailing-slash-redirect': skip_trailing_slash_redirect_1.default,
31
- 'check-locale': check_locale_1.default,
32
- 'meta-data-import': meta_data_import_1.default,
33
- 'check-middleware-order': check_middleware_order_1.default,
34
- 'urls-without-slash': urls_without_slash_1.default,
35
- 'invalid-imports': invalid_imports_1.default,
36
- 'check-menu-depth': check_menu_depth_1.default,
37
- 'case-warning': case_warning_1.default
18
+ 'client-url': client_url_1.default,
19
+ 'image-import': image_import_1.default,
20
+ 'link-import': link_import_1.default,
21
+ 'router-import': router_import_1.default,
22
+ 'skip-trailing-slash-redirect': skip_trailing_slash_redirect_1.default,
23
+ 'check-locale': check_locale_1.default,
24
+ 'meta-data-import': meta_data_import_1.default,
25
+ 'check-middleware-order': check_middleware_order_1.default,
26
+ 'urls-without-slash': urls_without_slash_1.default,
27
+ 'invalid-imports': invalid_imports_1.default
38
28
  };
39
29
  exports.rules = rules;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/eslint-plugin-projectzero",
3
- "version": "1.43.0-rc.6",
3
+ "version": "1.43.0",
4
4
  "private": false,
5
5
  "description": "ESLint plugin for Project Zero Next",
6
6
  "main": "dist/index.js",
package/rules/index.ts CHANGED
@@ -8,8 +8,6 @@ import metaDataImport from './meta-data-import';
8
8
  import checkMiddlewareOrder from './check-middleware-order';
9
9
  import urlsWithoutSlash from './urls-without-slash';
10
10
  import invalidImports from './invalid-imports';
11
- import checkMenuDepth from './check-menu-depth';
12
- import caseWarning from './case-warning';
13
11
 
14
12
  const rules = {
15
13
  'client-url': clientUrl,
@@ -21,9 +19,7 @@ const rules = {
21
19
  'meta-data-import': metaDataImport,
22
20
  'check-middleware-order': checkMiddlewareOrder,
23
21
  'urls-without-slash': urlsWithoutSlash,
24
- 'invalid-imports': invalidImports,
25
- 'check-menu-depth': checkMenuDepth,
26
- 'case-warning': caseWarning
22
+ 'invalid-imports': invalidImports
27
23
  };
28
24
 
29
25
  export { rules };
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("@typescript-eslint/utils");
4
- exports.default = utils_1.ESLintUtils.RuleCreator.withoutDocs({
5
- create(context) {
6
- return {
7
- CallExpression(node) {
8
- if (node.callee.type === 'MemberExpression' &&
9
- node.callee.property.type === 'Identifier' &&
10
- (node.callee.property.name === 'toLocaleUpperCase' ||
11
- node.callee.property.name === 'toLocaleLowerCase')) {
12
- const args = node.arguments;
13
- if (args.length === 0) {
14
- context.report({
15
- node,
16
- messageId: 'noLocale'
17
- });
18
- }
19
- }
20
- }
21
- };
22
- },
23
- meta: {
24
- messages: {
25
- noLocale: 'toLocaleUpperCase() or toLocaleLowerCase() should specify a locale for consistent behavior across different environments.'
26
- },
27
- type: 'problem',
28
- fixable: 'code',
29
- schema: []
30
- },
31
- defaultOptions: []
32
- });
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("@typescript-eslint/utils");
4
- const types_1 = require("@typescript-eslint/types");
5
- exports.default = utils_1.ESLintUtils.RuleCreator.withoutDocs({
6
- create: function (context) {
7
- return {
8
- CallExpression(node) {
9
- const { callee, arguments: args } = node;
10
- if (callee.type !== types_1.AST_NODE_TYPES.Identifier ||
11
- callee.name !== 'getMenu' ||
12
- args.length === 0 ||
13
- args[0].type !== types_1.AST_NODE_TYPES.ObjectExpression) {
14
- return;
15
- }
16
- const depthProperty = args[0].properties.find((prop) => {
17
- var _a;
18
- return prop.type === types_1.AST_NODE_TYPES.Property &&
19
- prop.key.type === types_1.AST_NODE_TYPES.Identifier &&
20
- prop.key.name === 'depth' &&
21
- ((_a = prop.value) === null || _a === void 0 ? void 0 : _a.type) === types_1.AST_NODE_TYPES.Literal &&
22
- typeof prop.value.value === 'number' &&
23
- prop.value.value > 3;
24
- });
25
- if (depthProperty) {
26
- context.report({
27
- node: depthProperty,
28
- messageId: 'depthMessage'
29
- });
30
- }
31
- }
32
- };
33
- },
34
- meta: {
35
- type: 'problem',
36
- fixable: 'code',
37
- messages: {
38
- depthMessage: 'A request for a menu deeper than 3 levels from the server can lead to unnecessary memory usage and unwanted outcomes. Therefore, sending a request for a 3-level menu on the client side and making additional requests on hover for deeper levels may be more efficient.'
39
- },
40
- schema: []
41
- },
42
- defaultOptions: []
43
- });
@@ -1,39 +0,0 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- import { TSESTree } from '@typescript-eslint/types';
3
-
4
- type MessageIds = 'noLocale';
5
- type Options = readonly [];
6
-
7
- export default ESLintUtils.RuleCreator.withoutDocs<Options, MessageIds>({
8
- create(context) {
9
- return {
10
- CallExpression(node: TSESTree.CallExpression) {
11
- if (
12
- node.callee.type === 'MemberExpression' &&
13
- node.callee.property.type === 'Identifier' &&
14
- (node.callee.property.name === 'toLocaleUpperCase' ||
15
- node.callee.property.name === 'toLocaleLowerCase')
16
- ) {
17
- const args = node.arguments;
18
-
19
- if (args.length === 0) {
20
- context.report({
21
- node,
22
- messageId: 'noLocale'
23
- });
24
- }
25
- }
26
- }
27
- };
28
- },
29
- meta: {
30
- messages: {
31
- noLocale:
32
- 'toLocaleUpperCase() or toLocaleLowerCase() should specify a locale for consistent behavior across different environments.'
33
- },
34
- type: 'problem',
35
- fixable: 'code',
36
- schema: []
37
- },
38
- defaultOptions: []
39
- });
@@ -1,48 +0,0 @@
1
- import { ESLintUtils } from '@typescript-eslint/utils';
2
- import { AST_NODE_TYPES } from '@typescript-eslint/types';
3
-
4
- export default ESLintUtils.RuleCreator.withoutDocs({
5
- create: function (context) {
6
- return {
7
- CallExpression(node) {
8
- const { callee, arguments: args } = node;
9
-
10
- if (
11
- callee.type !== AST_NODE_TYPES.Identifier ||
12
- callee.name !== 'getMenu' ||
13
- args.length === 0 ||
14
- args[0].type !== AST_NODE_TYPES.ObjectExpression
15
- ) {
16
- return;
17
- }
18
-
19
- const depthProperty = args[0].properties.find(
20
- (prop) =>
21
- prop.type === AST_NODE_TYPES.Property &&
22
- prop.key.type === AST_NODE_TYPES.Identifier &&
23
- prop.key.name === 'depth' &&
24
- prop.value?.type === AST_NODE_TYPES.Literal &&
25
- typeof prop.value.value === 'number' &&
26
- prop.value.value > 3
27
- );
28
-
29
- if (depthProperty) {
30
- context.report({
31
- node: depthProperty,
32
- messageId: 'depthMessage'
33
- });
34
- }
35
- }
36
- };
37
- },
38
- meta: {
39
- type: 'problem',
40
- fixable: 'code',
41
- messages: {
42
- depthMessage:
43
- 'A request for a menu deeper than 3 levels from the server can lead to unnecessary memory usage and unwanted outcomes. Therefore, sending a request for a 3-level menu on the client side and making additional requests on hover for deeper levels may be more efficient.'
44
- },
45
- schema: []
46
- },
47
- defaultOptions: []
48
- });