eslint-plugin-cvsdk-rules 8.2.4 → 8.2.5-preview-no-audio-fix
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/config/file.ts +1 -1
- package/config/tsconfig.json +10 -10
- package/index.js +6 -6
- package/jest.config.js +2 -2
- package/package.json +2 -2
- package/rules/prefer-self-over-window.js +41 -41
- package/rules/prefer-self-over-window.spec.js +40 -40
- package/rules/prefer-txml-over-domparser.js +26 -26
package/config/file.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
// See: https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
|
1
|
+
// See: https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
package/config/tsconfig.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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"]
|
|
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
11
|
}
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
'prefer-self-over-window': require('./rules/prefer-self-over-window'),
|
|
4
|
-
'prefer-txml-over-domparser': require('./rules/prefer-txml-over-domparser'),
|
|
5
|
-
},
|
|
6
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
rules: {
|
|
3
|
+
'prefer-self-over-window': require('./rules/prefer-self-over-window'),
|
|
4
|
+
'prefer-txml-over-domparser': require('./rules/prefer-txml-over-domparser'),
|
|
5
|
+
},
|
|
6
|
+
};
|
package/jest.config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
{
|
|
2
|
-
}
|
|
1
|
+
{
|
|
2
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-cvsdk-rules",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.5-preview-no-audio-fix",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -13,5 +13,5 @@
|
|
|
13
13
|
"@typescript-eslint/rule-tester": "6.21.0",
|
|
14
14
|
"jest": "29.7.0"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "be9dd3e0acd90c08777a0a0ed1edf9c248359001"
|
|
17
17
|
}
|
|
@@ -1,41 +1,41 @@
|
|
|
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
|
+
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,40 +1,40 @@
|
|
|
1
|
-
const { RuleTester } = require('@typescript-eslint/rule-tester');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const rule = require('./prefer-self-over-window');
|
|
5
|
-
|
|
6
|
-
const ruleName = 'prefer-self-over-window';
|
|
7
|
-
|
|
8
|
-
// https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
|
9
|
-
const ruleTester = new RuleTester({
|
|
10
|
-
parser: require.resolve('@typescript-eslint/parser'),
|
|
11
|
-
parserOptions: {
|
|
12
|
-
project: true,
|
|
13
|
-
tsconfigRootDir: path.join(__dirname, '../config'),
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('Disallow window access', () => {
|
|
18
|
-
ruleTester.run(ruleName, rule, {
|
|
19
|
-
invalid: [
|
|
20
|
-
{
|
|
21
|
-
code: 'window;',
|
|
22
|
-
output: 'self;',
|
|
23
|
-
errors: [{ messageId: 'forbiddenWindowAccess' }],
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
code: 'declare let window: any; window;',
|
|
27
|
-
output: 'declare let window: any; self;',
|
|
28
|
-
errors: [{ messageId: 'forbiddenWindowAccess' }],
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
valid: [
|
|
32
|
-
'const window = 1;',
|
|
33
|
-
'function someFunc() { const window = 1; window; }',
|
|
34
|
-
'function someFunc() { let window: number; window; };',
|
|
35
|
-
'function someFunc() { let window: unknown; window; };',
|
|
36
|
-
'function someFunc() { let window: any; window; };',
|
|
37
|
-
'function someFunc() { let window; window; };',
|
|
38
|
-
],
|
|
39
|
-
});
|
|
40
|
-
});
|
|
1
|
+
const { RuleTester } = require('@typescript-eslint/rule-tester');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const rule = require('./prefer-self-over-window');
|
|
5
|
+
|
|
6
|
+
const ruleName = 'prefer-self-over-window';
|
|
7
|
+
|
|
8
|
+
// https://typescript-eslint.io/packages/rule-tester/#type-aware-testing
|
|
9
|
+
const ruleTester = new RuleTester({
|
|
10
|
+
parser: require.resolve('@typescript-eslint/parser'),
|
|
11
|
+
parserOptions: {
|
|
12
|
+
project: true,
|
|
13
|
+
tsconfigRootDir: path.join(__dirname, '../config'),
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('Disallow window access', () => {
|
|
18
|
+
ruleTester.run(ruleName, rule, {
|
|
19
|
+
invalid: [
|
|
20
|
+
{
|
|
21
|
+
code: 'window;',
|
|
22
|
+
output: 'self;',
|
|
23
|
+
errors: [{ messageId: 'forbiddenWindowAccess' }],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
code: 'declare let window: any; window;',
|
|
27
|
+
output: 'declare let window: any; self;',
|
|
28
|
+
errors: [{ messageId: 'forbiddenWindowAccess' }],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
valid: [
|
|
32
|
+
'const window = 1;',
|
|
33
|
+
'function someFunc() { const window = 1; window; }',
|
|
34
|
+
'function someFunc() { let window: number; window; };',
|
|
35
|
+
'function someFunc() { let window: unknown; window; };',
|
|
36
|
+
'function someFunc() { let window: any; window; };',
|
|
37
|
+
'function someFunc() { let window; window; };',
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -1,26 +1,26 @@
|
|
|
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
|
-
};
|
|
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
|
+
};
|