eslint-plugin-cvsdk-rules 14.0.2-protected → 14.1.0-alpha.2-protected
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/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -0
- package/build/index.js.map +1 -1
- package/build/rules/no-device-type-imports.d.ts +3 -0
- package/build/rules/no-device-type-imports.d.ts.map +1 -0
- package/build/rules/no-device-type-imports.js +36 -0
- package/build/rules/no-device-type-imports.js.map +1 -0
- package/build/rules/prefer-private-exposables.d.ts +3 -0
- package/build/rules/prefer-private-exposables.d.ts.map +1 -0
- package/build/rules/prefer-private-exposables.js +30 -0
- package/build/rules/prefer-private-exposables.js.map +1 -0
- package/package.json +25 -25
- package/src/index.ts +4 -0
- package/src/rules/no-device-type-imports.ts +41 -0
- package/src/rules/prefer-private-exposables.ts +30 -0
package/build/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ declare const plugin: {
|
|
|
3
3
|
'prefer-no-lodash-cloneDeep': import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"forbiddenCloneDeepUsage", never[], unknown, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener>;
|
|
4
4
|
'prefer-self-over-window': import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"forbiddenWindowAccess", never[], unknown, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener>;
|
|
5
5
|
'prefer-txml-over-domparser': import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"forbiddenDomParserUsage", never[], unknown, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener>;
|
|
6
|
+
'no-device-type-imports': import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"forbiddenDeviceTypeUsage" | "forbiddenDeviceTypeUtilUsage", never[], unknown, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener>;
|
|
7
|
+
'prefer-private-exposables': import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleModule<"preferPrivateExposable", never[], unknown, import("@typescript-eslint/utils/dist/ts-eslint/Rule.js").RuleListener>;
|
|
6
8
|
};
|
|
7
9
|
};
|
|
8
10
|
export { plugin };
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,QAAA,MAAM,MAAM;;;;;;;;CAEX,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { rule as preferSelfOverWindow } from './rules/prefer-self-over-window.js';
|
|
2
2
|
import { rule as preferTxmlOverDomParser } from './rules/prefer-txml-over-domparser.js';
|
|
3
3
|
import { rule as preferNoLodashCloneDeep } from './rules/prefer-no-lodash-clone-deep.js';
|
|
4
|
+
import { rule as noDeviceTypeImports } from './rules/no-device-type-imports.js';
|
|
5
|
+
import { rule as preferPrivateExposables } from './rules/prefer-private-exposables.js';
|
|
4
6
|
var rules = {
|
|
5
7
|
'prefer-no-lodash-cloneDeep': preferNoLodashCloneDeep,
|
|
6
8
|
'prefer-self-over-window': preferSelfOverWindow,
|
|
7
9
|
'prefer-txml-over-domparser': preferTxmlOverDomParser,
|
|
10
|
+
'no-device-type-imports': noDeviceTypeImports,
|
|
11
|
+
'prefer-private-exposables': preferPrivateExposables,
|
|
8
12
|
};
|
|
9
13
|
var plugin = {
|
|
10
14
|
rules: rules,
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,IAAI,IAAI,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,IAAI,IAAI,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,IAAI,IAAI,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,IAAI,IAAI,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,IAAI,IAAI,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,IAAI,IAAI,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAEvF,IAAM,KAAK,GAAG;IACV,4BAA4B,EAAE,uBAAuB;IACrD,yBAAyB,EAAE,oBAAoB;IAC/C,4BAA4B,EAAE,uBAAuB;IACrD,wBAAwB,EAAE,mBAAmB;IAC7C,2BAA2B,EAAE,uBAAuB;CACvD,CAAC;AAEF,IAAM,MAAM,GAAG;IACX,KAAK,OAAA;CACR,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-device-type-imports.d.ts","sourceRoot":"","sources":["../../src/rules/no-device-type-imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAItE,eAAO,MAAM,IAAI,iIAoCf,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
var createRule = ESLintUtils.RuleCreator(function (name) { return name; });
|
|
3
|
+
export var rule = createRule({
|
|
4
|
+
create: function (context) {
|
|
5
|
+
return {
|
|
6
|
+
"Program:has(ImportDeclaration[source.value='@sky-uk-ott/client-lib-js-device'] > ImportSpecifier[imported.name=DeviceType])": function (node) {
|
|
7
|
+
context.report({
|
|
8
|
+
node: node,
|
|
9
|
+
messageId: 'forbiddenDeviceTypeUsage',
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
// Note the unicode character here is required to match a forward slash in the import path
|
|
13
|
+
// See https://eslint.org/docs/latest/extend/selectors#known-issues
|
|
14
|
+
'Program:has(ImportDeclaration[source.value=/.*\\u002Fdevice-type/])': function (node) {
|
|
15
|
+
context.report({
|
|
16
|
+
node: node,
|
|
17
|
+
messageId: 'forbiddenDeviceTypeUtilUsage',
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
name: 'no-device-type-imports',
|
|
23
|
+
meta: {
|
|
24
|
+
docs: {
|
|
25
|
+
description: 'Detect DeviceType usage in the CVSDK',
|
|
26
|
+
},
|
|
27
|
+
messages: {
|
|
28
|
+
forbiddenDeviceTypeUsage: 'This portion of the CVSDK is device agnostic. Please do not directly use DeviceType for device specific functionality.',
|
|
29
|
+
forbiddenDeviceTypeUtilUsage: 'This portion of the CVSDK is device agnostic. Please do not directly use the utils/device-type module for device specific functionality.',
|
|
30
|
+
},
|
|
31
|
+
schema: [],
|
|
32
|
+
type: 'problem',
|
|
33
|
+
},
|
|
34
|
+
defaultOptions: [],
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=no-device-type-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-device-type-imports.js","sourceRoot":"","sources":["../../src/rules/no-device-type-imports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAEtE,IAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,EAAJ,CAAI,CAAC,CAAC;AAE3D,MAAM,CAAC,IAAM,IAAI,GAAG,UAAU,CAAC;IAC3B,MAAM,YAAC,OAAO;QACV,OAAO;YACH,6HAA6H,EAAE,UAC3H,IAAoC;gBAEpC,OAAO,CAAC,MAAM,CAAC;oBACX,IAAI,MAAA;oBACJ,SAAS,EAAE,0BAA0B;iBACxC,CAAC,CAAC;YACP,CAAC;YACD,0FAA0F;YAC1F,mEAAmE;YACnE,qEAAqE,EAAE,UAAC,IAAI;gBACxE,OAAO,CAAC,MAAM,CAAC;oBACX,IAAI,MAAA;oBACJ,SAAS,EAAE,8BAA8B;iBAC5C,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;IACD,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACF,IAAI,EAAE;YACF,WAAW,EAAE,sCAAsC;SACtD;QACD,QAAQ,EAAE;YACN,wBAAwB,EACpB,wHAAwH;YAC5H,4BAA4B,EACxB,0IAA0I;SACjJ;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,cAAc,EAAE,EAAE;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-private-exposables.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-private-exposables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAItE,eAAO,MAAM,IAAI,8FAyBf,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
var createRule = ESLintUtils.RuleCreator(function (name) { return name; });
|
|
3
|
+
export var rule = createRule({
|
|
4
|
+
create: function (context) {
|
|
5
|
+
var _a;
|
|
6
|
+
var publicExposableNames = ['Ad', 'AdBreak', 'AdPosition', 'Track'];
|
|
7
|
+
var selector = publicExposableNames.map(function (name) { return "ImportSpecifier[imported.name=".concat(name, "]"); }).join(', ');
|
|
8
|
+
return _a = {},
|
|
9
|
+
_a["Program:has(".concat(selector, ")")] = function (node) {
|
|
10
|
+
context.report({
|
|
11
|
+
node: node,
|
|
12
|
+
messageId: 'preferPrivateExposable',
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
_a;
|
|
16
|
+
},
|
|
17
|
+
name: 'prefer-private-exposables',
|
|
18
|
+
meta: {
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Prefer private versions of exposables within CVSDK core',
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
preferPrivateExposable: 'Please use Internal variant of public data type (eg. AdBreakInternal instead of AdBreak) inside the core',
|
|
24
|
+
},
|
|
25
|
+
schema: [],
|
|
26
|
+
type: 'problem',
|
|
27
|
+
},
|
|
28
|
+
defaultOptions: [],
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=prefer-private-exposables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-private-exposables.js","sourceRoot":"","sources":["../../src/rules/prefer-private-exposables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAEtE,IAAM,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,EAAJ,CAAI,CAAC,CAAC;AAE3D,MAAM,CAAC,IAAM,IAAI,GAAG,UAAU,CAAC;IAC3B,MAAM,YAAC,OAAO;;QACV,IAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACtE,IAAM,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,wCAAiC,IAAI,MAAG,EAAxC,CAAwC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzG;YACI,GAAC,sBAAe,QAAQ,MAAG,IAAG,UAAC,IAAoC;gBAC/D,OAAO,CAAC,MAAM,CAAC;oBACX,IAAI,MAAA;oBACJ,SAAS,EAAE,wBAAwB;iBACtC,CAAC,CAAC;YACP,CAAC;eACH;IACN,CAAC;IACD,IAAI,EAAE,2BAA2B;IACjC,IAAI,EAAE;QACF,IAAI,EAAE;YACF,WAAW,EAAE,yDAAyD;SACzE;QACD,QAAQ,EAAE;YACN,sBAAsB,EAAE,0GAA0G;SACrI;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,cAAc,EAAE,EAAE;CACrB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
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
|
-
}
|
|
2
|
+
"name": "eslint-plugin-cvsdk-rules",
|
|
3
|
+
"version": "14.1.0-alpha.2-protected",
|
|
4
|
+
"main": "./build/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"typescript-eslint": "8.8.0"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@eslint/js": "^9.8.0",
|
|
11
|
+
"@types/eslint": "^9.6.0",
|
|
12
|
+
"@types/eslint__js": "^8.42.3",
|
|
13
|
+
"@types/node": "^22.0.2",
|
|
14
|
+
"@typescript-eslint/utils": "8.34.0",
|
|
15
|
+
"@typescript-eslint/rule-tester": "8.8.0",
|
|
16
|
+
"console-fail-test": "^0.5.0",
|
|
17
|
+
"eslint": "^9.8.0",
|
|
18
|
+
"eslint-plugin-eslint-plugin": "6.2.0",
|
|
19
|
+
"typescript": "5.2.2"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "jest",
|
|
23
|
+
"test:nocoverage": "jest",
|
|
24
|
+
"build": "tsc"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { rule as preferSelfOverWindow } from './rules/prefer-self-over-window.js';
|
|
2
2
|
import { rule as preferTxmlOverDomParser } from './rules/prefer-txml-over-domparser.js';
|
|
3
3
|
import { rule as preferNoLodashCloneDeep } from './rules/prefer-no-lodash-clone-deep.js';
|
|
4
|
+
import { rule as noDeviceTypeImports } from './rules/no-device-type-imports.js';
|
|
5
|
+
import { rule as preferPrivateExposables } from './rules/prefer-private-exposables.js';
|
|
4
6
|
|
|
5
7
|
const rules = {
|
|
6
8
|
'prefer-no-lodash-cloneDeep': preferNoLodashCloneDeep,
|
|
7
9
|
'prefer-self-over-window': preferSelfOverWindow,
|
|
8
10
|
'prefer-txml-over-domparser': preferTxmlOverDomParser,
|
|
11
|
+
'no-device-type-imports': noDeviceTypeImports,
|
|
12
|
+
'prefer-private-exposables': preferPrivateExposables,
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
const plugin = {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ESLintUtils, type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
const createRule = ESLintUtils.RuleCreator((name) => name);
|
|
4
|
+
|
|
5
|
+
export const rule = createRule({
|
|
6
|
+
create(context) {
|
|
7
|
+
return {
|
|
8
|
+
"Program:has(ImportDeclaration[source.value='@sky-uk-ott/client-lib-js-device'] > ImportSpecifier[imported.name=DeviceType])": (
|
|
9
|
+
node: TSESTree.Node | TSESTree.Token
|
|
10
|
+
) => {
|
|
11
|
+
context.report({
|
|
12
|
+
node,
|
|
13
|
+
messageId: 'forbiddenDeviceTypeUsage',
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
// Note the unicode character here is required to match a forward slash in the import path
|
|
17
|
+
// See https://eslint.org/docs/latest/extend/selectors#known-issues
|
|
18
|
+
'Program:has(ImportDeclaration[source.value=/.*\\u002Fdevice-type/])': (node) => {
|
|
19
|
+
context.report({
|
|
20
|
+
node,
|
|
21
|
+
messageId: 'forbiddenDeviceTypeUtilUsage',
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
name: 'no-device-type-imports',
|
|
27
|
+
meta: {
|
|
28
|
+
docs: {
|
|
29
|
+
description: 'Detect DeviceType usage in the CVSDK',
|
|
30
|
+
},
|
|
31
|
+
messages: {
|
|
32
|
+
forbiddenDeviceTypeUsage:
|
|
33
|
+
'This portion of the CVSDK is device agnostic. Please do not directly use DeviceType for device specific functionality.',
|
|
34
|
+
forbiddenDeviceTypeUtilUsage:
|
|
35
|
+
'This portion of the CVSDK is device agnostic. Please do not directly use the utils/device-type module for device specific functionality.',
|
|
36
|
+
},
|
|
37
|
+
schema: [],
|
|
38
|
+
type: 'problem',
|
|
39
|
+
},
|
|
40
|
+
defaultOptions: [],
|
|
41
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ESLintUtils, type TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
const createRule = ESLintUtils.RuleCreator((name) => name);
|
|
4
|
+
|
|
5
|
+
export const rule = createRule({
|
|
6
|
+
create(context) {
|
|
7
|
+
const publicExposableNames = ['Ad', 'AdBreak', 'AdPosition', 'Track'];
|
|
8
|
+
const selector = publicExposableNames.map((name) => `ImportSpecifier[imported.name=${name}]`).join(', ');
|
|
9
|
+
return {
|
|
10
|
+
[`Program:has(${selector})`]: (node: TSESTree.Node | TSESTree.Token) => {
|
|
11
|
+
context.report({
|
|
12
|
+
node,
|
|
13
|
+
messageId: 'preferPrivateExposable',
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
name: 'prefer-private-exposables',
|
|
19
|
+
meta: {
|
|
20
|
+
docs: {
|
|
21
|
+
description: 'Prefer private versions of exposables within CVSDK core',
|
|
22
|
+
},
|
|
23
|
+
messages: {
|
|
24
|
+
preferPrivateExposable: 'Please use Internal variant of public data type (eg. AdBreakInternal instead of AdBreak) inside the core',
|
|
25
|
+
},
|
|
26
|
+
schema: [],
|
|
27
|
+
type: 'problem',
|
|
28
|
+
},
|
|
29
|
+
defaultOptions: [],
|
|
30
|
+
});
|