eslint-plugin-cvsdk-rules 1.0.0-test2 → 1.0.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/build/index.d.ts +11 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +17 -0
- package/build/index.js.map +1 -0
- 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-no-lodash-clone-deep.d.ts +3 -0
- package/build/rules/prefer-no-lodash-clone-deep.d.ts.map +1 -0
- package/build/rules/prefer-no-lodash-clone-deep.js +27 -0
- package/build/rules/prefer-no-lodash-clone-deep.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/build/rules/prefer-self-over-window.d.ts +3 -0
- package/build/rules/prefer-self-over-window.d.ts.map +1 -0
- package/build/rules/prefer-self-over-window.js +38 -0
- package/build/rules/prefer-self-over-window.js.map +1 -0
- package/build/rules/prefer-txml-over-domparser.d.ts +3 -0
- package/build/rules/prefer-txml-over-domparser.d.ts.map +1 -0
- package/build/rules/prefer-txml-over-domparser.js +27 -0
- package/build/rules/prefer-txml-over-domparser.js.map +1 -0
- package/jest.config.js +40 -2
- package/package.json +25 -17
- package/src/index.ts +19 -0
- package/src/rules/no-device-type-imports.ts +41 -0
- package/src/rules/prefer-no-lodash-clone-deep.ts +29 -0
- package/src/rules/prefer-private-exposables.ts +30 -0
- package/{rules/prefer-self-over-window.spec.js → src/rules/prefer-self-over-window.spec.ts} +15 -10
- package/src/rules/prefer-self-over-window.ts +41 -0
- package/src/rules/prefer-txml-over-domparser.ts +28 -0
- package/tsconfig.json +25 -0
- package/config/file.ts +0 -1
- package/config/tsconfig.json +0 -11
- package/index.js +0 -6
- package/rules/prefer-self-over-window.js +0 -41
- package/rules/prefer-txml-over-domparser.js +0 -26
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const plugin: {
|
|
2
|
+
rules: {
|
|
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
|
+
'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
|
+
'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>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export { plugin };
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { rule as preferSelfOverWindow } from './rules/prefer-self-over-window.js';
|
|
2
|
+
import { rule as preferTxmlOverDomParser } from './rules/prefer-txml-over-domparser.js';
|
|
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';
|
|
6
|
+
var rules = {
|
|
7
|
+
'prefer-no-lodash-cloneDeep': preferNoLodashCloneDeep,
|
|
8
|
+
'prefer-self-over-window': preferSelfOverWindow,
|
|
9
|
+
'prefer-txml-over-domparser': preferTxmlOverDomParser,
|
|
10
|
+
'no-device-type-imports': noDeviceTypeImports,
|
|
11
|
+
'prefer-private-exposables': preferPrivateExposables,
|
|
12
|
+
};
|
|
13
|
+
var plugin = {
|
|
14
|
+
rules: rules,
|
|
15
|
+
};
|
|
16
|
+
export { plugin };
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;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-no-lodash-clone-deep.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-no-lodash-clone-deep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,eAAO,MAAM,IAAI,+FAwBf,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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='lodash'] > ImportSpecifier[imported.name=cloneDeep]) CallExpression[callee.name=cloneDeep]": function (node) {
|
|
7
|
+
context.report({
|
|
8
|
+
node: node,
|
|
9
|
+
messageId: 'forbiddenCloneDeepUsage',
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
name: 'prefer-no-lodash-cloneDeep',
|
|
15
|
+
meta: {
|
|
16
|
+
docs: {
|
|
17
|
+
description: 'Detect usage of Lodash cloneDeep',
|
|
18
|
+
},
|
|
19
|
+
messages: {
|
|
20
|
+
forbiddenCloneDeepUsage: "Prefer using rfdc (@sky-uk-ott/core-video-sdk-js-external-rfdc) over lodash.cloneDeep as it cost a lot in performance",
|
|
21
|
+
},
|
|
22
|
+
schema: [],
|
|
23
|
+
type: 'problem',
|
|
24
|
+
},
|
|
25
|
+
defaultOptions: [],
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=prefer-no-lodash-clone-deep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-no-lodash-clone-deep.js","sourceRoot":"","sources":["../../src/rules/prefer-no-lodash-clone-deep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,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,wIAAwI,EACpI,UAAC,IAAI;gBACD,OAAO,CAAC,MAAM,CAAC;oBACX,IAAI,MAAA;oBACJ,SAAS,EAAE,yBAAyB;iBACvC,CAAC,CAAC;YACP,CAAC;SACR,CAAC;IACN,CAAC;IACD,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE;QACF,IAAI,EAAE;YACF,WAAW,EAAE,kCAAkC;SAClD;QACD,QAAQ,EAAE;YACN,uBAAuB,EAAE,uHAAuH;SACnJ;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-self-over-window.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-self-over-window.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,0BAA0B,CAAC;AAItE,eAAO,MAAM,IAAI,6FAoCf,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 parserServices = ESLintUtils.getParserServices(context);
|
|
6
|
+
function reportWindowError(node) {
|
|
7
|
+
if (node.parent.type !== 'VariableDeclarator') {
|
|
8
|
+
var nodeType = parserServices.getTypeAtLocation(node);
|
|
9
|
+
if (Object.prototype.hasOwnProperty.call(nodeType, 'aliasSymbol')) {
|
|
10
|
+
context.report({
|
|
11
|
+
messageId: 'forbiddenWindowAccess',
|
|
12
|
+
node: node,
|
|
13
|
+
fix: function (fixer) {
|
|
14
|
+
return fixer.replaceText(node, 'self');
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
"Identifier[name='window']": reportWindowError,
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
name: 'uppercase-first-declarations',
|
|
25
|
+
meta: {
|
|
26
|
+
docs: {
|
|
27
|
+
description: 'Disallow window access.',
|
|
28
|
+
},
|
|
29
|
+
messages: {
|
|
30
|
+
forbiddenWindowAccess: '`window` cannot be accessed inside some containers, we prefer using `self` as it has more compatibility.',
|
|
31
|
+
},
|
|
32
|
+
schema: [],
|
|
33
|
+
type: 'problem',
|
|
34
|
+
fixable: 'code',
|
|
35
|
+
},
|
|
36
|
+
defaultOptions: [],
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=prefer-self-over-window.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-self-over-window.js","sourceRoot":"","sources":["../../src/rules/prefer-self-over-window.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,cAAc,GAAG,WAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAE9D,SAAS,iBAAiB,CAAC,IAAmB;YAC1C,IAAI,IAAI,CAAC,MAAO,CAAC,IAAI,KAAK,oBAAoB,EAAE;gBAC5C,IAAM,QAAQ,GAAG,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;gBACxD,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE;oBAC/D,OAAO,CAAC,MAAM,CAAC;wBACX,SAAS,EAAE,uBAAuB;wBAClC,IAAI,MAAA;wBACJ,GAAG,EAAE,UAAU,KAAK;4BAChB,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;wBAC3C,CAAC;qBACJ,CAAC,CAAC;iBACN;aACJ;QACL,CAAC;QAED,OAAO;YACH,2BAA2B,EAAE,iBAAiB;SACjD,CAAC;IACN,CAAC;IACD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE;QACF,IAAI,EAAE;YACF,WAAW,EAAE,yBAAyB;SACzC;QACD,QAAQ,EAAE;YACN,qBAAqB,EAAE,0GAA0G;SACpI;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,MAAM;KAClB;IACD,cAAc,EAAE,EAAE;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-txml-over-domparser.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-txml-over-domparser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,eAAO,MAAM,IAAI,+FAuBf,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
Identifier: function (node) {
|
|
7
|
+
if (node.type === 'Identifier' && node.name === 'DOMParser' && node.parent.type === 'NewExpression') {
|
|
8
|
+
context.report({
|
|
9
|
+
node: node,
|
|
10
|
+
messageId: 'forbiddenDomParserUsage',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
name: 'prefer-txml-over-domparser',
|
|
17
|
+
meta: {
|
|
18
|
+
docs: { description: 'Disallow DOMParser usage.' },
|
|
19
|
+
messages: {
|
|
20
|
+
forbiddenDomParserUsage: "Prefer using txml (https://www.npmjs.com/package/txml) over DOMParser as DOMParser isn't supported on ION.",
|
|
21
|
+
},
|
|
22
|
+
schema: [],
|
|
23
|
+
type: 'problem',
|
|
24
|
+
},
|
|
25
|
+
defaultOptions: [],
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=prefer-txml-over-domparser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-txml-over-domparser.js","sourceRoot":"","sources":["../../src/rules/prefer-txml-over-domparser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,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,UAAU,YAAC,IAAI;gBACX,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,eAAe,EAAE;oBACjG,OAAO,CAAC,MAAM,CAAC;wBACX,IAAI,MAAA;wBACJ,SAAS,EAAE,yBAAyB;qBACvC,CAAC,CAAC;iBACN;YACL,CAAC;SACJ,CAAC;IACN,CAAC;IACD,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE;QACF,IAAI,EAAE,EAAE,WAAW,EAAE,2BAA2B,EAAE;QAClD,QAAQ,EAAE;YACN,uBAAuB,EAAE,4GAA4G;SACxI;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,SAAS;KAClB;IACD,cAAc,EAAE,EAAE;CACrB,CAAC,CAAC"}
|
package/jest.config.js
CHANGED
|
@@ -1,2 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
collectCoverage: false,
|
|
5
|
+
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
|
|
6
|
+
coverageReporters: ['lcov'],
|
|
7
|
+
moduleFileExtensions: [
|
|
8
|
+
'ts',
|
|
9
|
+
'tsx',
|
|
10
|
+
'mts',
|
|
11
|
+
'mtsx',
|
|
12
|
+
'cjs',
|
|
13
|
+
'js',
|
|
14
|
+
'jsx',
|
|
15
|
+
'mjs',
|
|
16
|
+
'mjsx',
|
|
17
|
+
'json',
|
|
18
|
+
'node',
|
|
19
|
+
],
|
|
20
|
+
setupFilesAfterEnv: [
|
|
21
|
+
path.join(path.resolve(), 'node_modules/console-fail-test/setup.cjs'),
|
|
22
|
+
],
|
|
23
|
+
testRegex: ['./tests/.+\\.test\\.ts$', './src/rules/.+\\.spec\\.ts$'],
|
|
24
|
+
transform: {
|
|
25
|
+
'^.+\\.(t|j)sx?$': [
|
|
26
|
+
'@swc/jest',
|
|
27
|
+
{
|
|
28
|
+
jsc: {
|
|
29
|
+
target: 'es2019',
|
|
30
|
+
transform: {
|
|
31
|
+
react: {
|
|
32
|
+
runtime: 'automatic',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
workerIdleMemoryLimit: '300MB',
|
|
40
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
2
|
+
"name": "eslint-plugin-cvsdk-rules",
|
|
3
|
+
"version": "1.0.0",
|
|
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
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { rule as preferSelfOverWindow } from './rules/prefer-self-over-window.js';
|
|
2
|
+
import { rule as preferTxmlOverDomParser } from './rules/prefer-txml-over-domparser.js';
|
|
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';
|
|
6
|
+
|
|
7
|
+
const rules = {
|
|
8
|
+
'prefer-no-lodash-cloneDeep': preferNoLodashCloneDeep,
|
|
9
|
+
'prefer-self-over-window': preferSelfOverWindow,
|
|
10
|
+
'prefer-txml-over-domparser': preferTxmlOverDomParser,
|
|
11
|
+
'no-device-type-imports': noDeviceTypeImports,
|
|
12
|
+
'prefer-private-exposables': preferPrivateExposables,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const plugin = {
|
|
16
|
+
rules,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { 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,29 @@
|
|
|
1
|
+
import { ESLintUtils } 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='lodash'] > ImportSpecifier[imported.name=cloneDeep]) CallExpression[callee.name=cloneDeep]":
|
|
9
|
+
(node) => {
|
|
10
|
+
context.report({
|
|
11
|
+
node,
|
|
12
|
+
messageId: 'forbiddenCloneDeepUsage',
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
name: 'prefer-no-lodash-cloneDeep',
|
|
18
|
+
meta: {
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Detect usage of Lodash cloneDeep',
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
forbiddenCloneDeepUsage: `Prefer using rfdc (@sky-uk-ott/core-video-sdk-js-external-rfdc) over lodash.cloneDeep as it cost a lot in performance`,
|
|
24
|
+
},
|
|
25
|
+
schema: [],
|
|
26
|
+
type: 'problem',
|
|
27
|
+
},
|
|
28
|
+
defaultOptions: [],
|
|
29
|
+
});
|
|
@@ -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
|
+
});
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { rule } from '../../build/rules/prefer-self-over-window.js';
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ruleName = 'prefer-self-over-window';
|
|
6
|
+
console.log(`Root dir: ${path.join(__dirname, '../..')}`);
|
|
7
7
|
|
|
8
8
|
// https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
|
9
9
|
const ruleTester = new RuleTester({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parser: tseslint.parser,
|
|
12
|
+
parserOptions: {
|
|
13
|
+
projectService: {
|
|
14
|
+
allowDefaultProject: ['*.ts*'],
|
|
15
|
+
defaultProject: 'tsconfig.json',
|
|
16
|
+
},
|
|
17
|
+
tsconfigRootDir: path.join(__dirname, '../..'),
|
|
18
|
+
},
|
|
14
19
|
},
|
|
15
20
|
});
|
|
16
21
|
|
|
17
22
|
describe('Disallow window access', () => {
|
|
18
|
-
ruleTester.run(
|
|
23
|
+
ruleTester.run('prefer-self-over-window', rule, {
|
|
19
24
|
invalid: [
|
|
20
25
|
{
|
|
21
26
|
code: 'window;',
|
|
@@ -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
|
+
const parserServices = ESLintUtils.getParserServices(context);
|
|
8
|
+
|
|
9
|
+
function reportWindowError(node: TSESTree.Node) {
|
|
10
|
+
if (node.parent!.type !== 'VariableDeclarator') {
|
|
11
|
+
const nodeType = parserServices.getTypeAtLocation(node);
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(nodeType, 'aliasSymbol')) {
|
|
13
|
+
context.report({
|
|
14
|
+
messageId: 'forbiddenWindowAccess',
|
|
15
|
+
node,
|
|
16
|
+
fix: function (fixer) {
|
|
17
|
+
return fixer.replaceText(node, 'self');
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
"Identifier[name='window']": reportWindowError,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
name: 'uppercase-first-declarations',
|
|
29
|
+
meta: {
|
|
30
|
+
docs: {
|
|
31
|
+
description: 'Disallow window access.',
|
|
32
|
+
},
|
|
33
|
+
messages: {
|
|
34
|
+
forbiddenWindowAccess: '`window` cannot be accessed inside some containers, we prefer using `self` as it has more compatibility.',
|
|
35
|
+
},
|
|
36
|
+
schema: [], // no options
|
|
37
|
+
type: 'problem',
|
|
38
|
+
fixable: 'code',
|
|
39
|
+
},
|
|
40
|
+
defaultOptions: [],
|
|
41
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
const createRule = ESLintUtils.RuleCreator((name) => name);
|
|
4
|
+
|
|
5
|
+
export const rule = createRule({
|
|
6
|
+
create(context) {
|
|
7
|
+
return {
|
|
8
|
+
Identifier(node) {
|
|
9
|
+
if (node.type === 'Identifier' && node.name === 'DOMParser' && node.parent.type === 'NewExpression') {
|
|
10
|
+
context.report({
|
|
11
|
+
node,
|
|
12
|
+
messageId: 'forbiddenDomParserUsage',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
name: 'prefer-txml-over-domparser',
|
|
19
|
+
meta: {
|
|
20
|
+
docs: { description: 'Disallow DOMParser usage.' },
|
|
21
|
+
messages: {
|
|
22
|
+
forbiddenDomParserUsage: `Prefer using txml (https://www.npmjs.com/package/txml) over DOMParser as DOMParser isn't supported on ION.`,
|
|
23
|
+
},
|
|
24
|
+
schema: [],
|
|
25
|
+
type: 'problem',
|
|
26
|
+
},
|
|
27
|
+
defaultOptions: [],
|
|
28
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "esnext",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"outDir": "build",
|
|
6
|
+
"declarationMap": true,
|
|
7
|
+
"downlevelIteration": true,
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"preserveConstEnums": true,
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"target": "es5",
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noUnusedLocals": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"importHelpers": true,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"jsx": "react",
|
|
20
|
+
"useDefineForClassFields": false,
|
|
21
|
+
"lib": ["dom", "dom.iterable", "es2017"]
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*.ts"],
|
|
24
|
+
"exclude": ["**/*.spec.ts"]
|
|
25
|
+
}
|
package/config/file.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// See: https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
package/config/tsconfig.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
// Otherwise TS will complain it'll override the base project's output
|
|
5
|
-
"outDir": "./",
|
|
6
|
-
"strict": true
|
|
7
|
-
},
|
|
8
|
-
"exclude": [],
|
|
9
|
-
// See: https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
|
10
|
-
"include": ["file.ts"]
|
|
11
|
-
}
|
package/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const { ESLintUtils } = require('@typescript-eslint/utils');
|
|
2
|
-
|
|
3
|
-
const meta = {
|
|
4
|
-
docs: {
|
|
5
|
-
description: 'Disallow window access.',
|
|
6
|
-
},
|
|
7
|
-
messages: {
|
|
8
|
-
forbiddenWindowAccess: '`window` cannot be accessed inside some containers, we prefer using `self` as it has more compatibility.',
|
|
9
|
-
},
|
|
10
|
-
schema: [], // no options
|
|
11
|
-
type: 'problem',
|
|
12
|
-
fixable: 'code',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function create(context) {
|
|
16
|
-
const parserServices = ESLintUtils.getParserServices(context);
|
|
17
|
-
|
|
18
|
-
function reportWindowError(node) {
|
|
19
|
-
if (node.parent.type !== 'VariableDeclarator') {
|
|
20
|
-
const nodeType = parserServices.getTypeAtLocation(node);
|
|
21
|
-
if (Object.prototype.hasOwnProperty.call(nodeType, 'aliasSymbol')) {
|
|
22
|
-
context.report({
|
|
23
|
-
messageId: 'forbiddenWindowAccess',
|
|
24
|
-
node,
|
|
25
|
-
fix: function (fixer) {
|
|
26
|
-
return fixer.replaceText(node, 'self');
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
"Identifier[name='window']": reportWindowError,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = {
|
|
39
|
-
create,
|
|
40
|
-
meta,
|
|
41
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const meta = {
|
|
2
|
-
docs: 'Disallow DOMParser usage.',
|
|
3
|
-
messages: {
|
|
4
|
-
forbiddenDomParserUsage: `Prefer using txml (https://www.npmjs.com/package/txml) over DOMParser as DOMParser isn't supported on ION.`,
|
|
5
|
-
},
|
|
6
|
-
schema: [],
|
|
7
|
-
type: 'problem',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
function create(context) {
|
|
11
|
-
return {
|
|
12
|
-
Identifier(node) {
|
|
13
|
-
if (node.type === 'Identifier' && node.name === 'DOMParser' && node.parent.type === 'NewExpression') {
|
|
14
|
-
context.report({
|
|
15
|
-
node,
|
|
16
|
-
messageId: 'forbiddenDomParserUsage',
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
create,
|
|
25
|
-
meta,
|
|
26
|
-
};
|