@servicenow/eslint-plugin-sdk-app-plugin 4.4.1 → 4.5.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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @servicenow/eslint-plugin-sdk-app-plugin
2
2
 
3
+ > **Deprecated**: This package is no longer maintained and is published only as a stub to prevent install failures. It exports nothing and has no functionality.
4
+
3
5
  Plugin to disallow Browser and Node.js APIs not supported in rhino engine
4
6
 
5
7
  ## Installation
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ // Stub — this package has been deprecated and is published only to prevent install failures.
2
+ module.exports = {}
package/package.json CHANGED
@@ -1,35 +1,12 @@
1
1
  {
2
2
  "name": "@servicenow/eslint-plugin-sdk-app-plugin",
3
- "version": "4.4.1",
4
- "description": "Plugin to disallow Browser and Node.js APIs not supported in rhino engine",
5
- "keywords": [
6
- "eslint",
7
- "eslintplugin",
8
- "eslint-plugin"
9
- ],
10
- "main": "./lib/index.js",
11
- "exports": "./lib/index.js",
12
- "dependencies": {
13
- "@eslint-community/eslint-utils": "4.4.0",
14
- "eslint": "8.50.0",
15
- "eslint-plugin-n": "16.3.1",
16
- "eslint-plugin-es-x": "7.2.0",
17
- "eslint-plugin-eslint-plugin": "5.0.0",
18
- "globals": "13.23.0"
19
- },
20
- "devDependencies": {
21
- "mocha": "10.0.0",
22
- "npm-run-all": "4.1.5"
23
- },
24
- "peerDependencies": {
25
- "eslint": ">=8"
26
- },
3
+ "version": "4.5.0",
4
+ "description": "Deprecated this package is no longer maintained. Kept as a stub to prevent install failures.",
5
+ "main": "./index.js",
6
+ "exports": "./index.js",
27
7
  "license": "MIT",
28
8
  "engines": {
29
9
  "node": ">=20.18.0",
30
10
  "pnpm": ">=10.8.0"
31
- },
32
- "scripts": {
33
- "test": "mocha tests --recursive"
34
11
  }
35
12
  }
package/.eslintrc.js DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- parserOptions: {
3
- ecmaVersion: 'latest',
4
- },
5
- root: true,
6
- extends: ['eslint:recommended', 'plugin:eslint-plugin/recommended', 'plugin:n/recommended'],
7
- env: {
8
- node: true,
9
- },
10
- }
@@ -1,14 +0,0 @@
1
- const { getRestrictedGlobals } = require('../util/utility')
2
- const restrictedGlobals = getRestrictedGlobals()
3
-
4
- module.exports = {
5
- plugins: ['@servicenow/sdk-app-plugin'],
6
- rules: {
7
- '@servicenow/sdk-app-plugin/file-extension-in-import': ['error', 'always'],
8
- 'no-restricted-globals': ['error', ...restrictedGlobals],
9
- '@servicenow/sdk-app-plugin/no-dynamic-import': 'error',
10
- '@servicenow/sdk-app-plugin/no-regexp-lookbehind-assertions': 'error',
11
- '@servicenow/sdk-app-plugin/no-regexp-unicode-property-escapes': 'error',
12
- '@servicenow/sdk-app-plugin/no-unsupported-node-builtins': 'error',
13
- },
14
- }
package/lib/index.js DELETED
@@ -1,14 +0,0 @@
1
- module.exports = {
2
- configs: {
3
- recommended: require('./configs/recommended'),
4
- },
5
- rules: {
6
- 'file-extension-in-import': require('eslint-plugin-n/lib/rules/file-extension-in-import'),
7
- 'no-async-functions': require('eslint-plugin-es-x/lib/rules/no-async-functions'),
8
- 'no-promise': require('./rules/no-promise'),
9
- 'no-dynamic-import': require('eslint-plugin-es-x/lib/rules/no-dynamic-import'),
10
- 'no-regexp-lookbehind-assertions': require('eslint-plugin-es-x/lib/rules/no-regexp-lookbehind-assertions'),
11
- 'no-regexp-unicode-property-escapes': require('eslint-plugin-es-x/lib/rules/no-regexp-unicode-property-escapes'),
12
- 'no-unsupported-node-builtins': require('./rules/no-unsupported-node-builtins'),
13
- },
14
- }
@@ -1,45 +0,0 @@
1
- const PROMISE_STATIC_METHODS = {
2
- all: true,
3
- allSettled: true,
4
- any: true,
5
- race: true,
6
- reject: true,
7
- resolve: true,
8
- withResolvers: true,
9
- }
10
-
11
- module.exports = {
12
- meta: {
13
- docs: {
14
- description: 'disallow the `Promise` class.',
15
- category: 'ES2015',
16
- recommended: false,
17
- },
18
- fixable: null,
19
- messages: {
20
- forbidden: 'ES2015 Promise class is not supported in now platform.',
21
- },
22
- schema: [],
23
- type: 'problem',
24
- },
25
- create(context) {
26
- return {
27
- CallExpression(node) {
28
- if (
29
- node.callee.type === 'MemberExpression' &&
30
- node.callee.object.name === 'Promise' &&
31
- node.callee.object.type === 'Identifier' &&
32
- PROMISE_STATIC_METHODS[node.callee.property.name]
33
- ) {
34
- context.report({ context, node, messageId: 'forbidden' })
35
- }
36
- },
37
-
38
- NewExpression(node) {
39
- if (node.callee.name === 'Promise') {
40
- context.report({ context, node, messageId: 'forbidden' })
41
- }
42
- },
43
- }
44
- },
45
- }
@@ -1,37 +0,0 @@
1
- const { createTrackMap } = require('../util/utility')
2
- const { ReferenceTracker } = require('@eslint-community/eslint-utils')
3
-
4
- /** @type {import('eslint').Rule.RuleModule} */
5
- module.exports = {
6
- meta: {
7
- docs: {
8
- description: 'disallow unsupported Node.js built-in APIs',
9
- recommended: true,
10
- },
11
- messages: {
12
- forbidden: 'The {{name}} Node.js API is not supported in now platform.',
13
- },
14
- schema: [],
15
- type: 'problem',
16
- },
17
- create(context) {
18
- return {
19
- 'Program:exit'(node) {
20
- const sourceCode = context.sourceCode
21
- const tracker = new ReferenceTracker(sourceCode.getScope(node), { mode: 'legacy' })
22
- const trackMap = createTrackMap(false)
23
- const globalsTrackMap = createTrackMap(true)
24
-
25
- const references = [
26
- ...tracker.iterateCjsReferences(trackMap),
27
- ...tracker.iterateEsmReferences(trackMap),
28
- ...tracker.iterateGlobalReferences(globalsTrackMap),
29
- ]
30
-
31
- for (const { node, info } of references) {
32
- context.report({ node, messageId: 'forbidden', data: info })
33
- }
34
- },
35
- }
36
- },
37
- }
@@ -1,79 +0,0 @@
1
- const globals = require('globals')
2
- const { READ } = require('@eslint-community/eslint-utils')
3
-
4
- const globalsAllowList = ['console', 'fetch']
5
- const BROWSER_API_WARNING = 'Web APIs are not supported by the now platform'
6
- const NO_GLOBAL_THIS = 'ES2020 `globalThis` variable is not supported by the now platform'
7
-
8
- const getRestrictedGlobals = () => {
9
- const globalRules = [{ name: 'globalThis', message: NO_GLOBAL_THIS }]
10
- const browserRules = Object.keys(globals.browser)
11
- .filter((key) => !globalsAllowList.includes(key))
12
- .map((key) => {
13
- return {
14
- name: key,
15
- message: BROWSER_API_WARNING,
16
- }
17
- })
18
- return globalRules.concat(browserRules)
19
- }
20
-
21
- const coreNodeModules = [
22
- 'assert',
23
- 'buffer',
24
- 'child_process',
25
- 'cluster',
26
- 'crypto',
27
- 'dgram',
28
- 'dns',
29
- 'domain',
30
- 'events',
31
- 'freelist',
32
- 'fs',
33
- 'http',
34
- 'https',
35
- 'module',
36
- 'net',
37
- 'os',
38
- 'path',
39
- 'punycode',
40
- 'querystring',
41
- 'readline',
42
- 'repl',
43
- 'smalloc',
44
- 'stream',
45
- 'string_decoder',
46
- 'sys',
47
- 'timers',
48
- 'tls',
49
- 'tracing',
50
- 'tty',
51
- 'url',
52
- 'util',
53
- 'vm',
54
- 'zlib',
55
- ]
56
-
57
- const getNodeGlobals = () => Object.keys(globals.nodeBuiltin).filter((key) => !globalsAllowList.includes(key))
58
-
59
- const createTrackMap = (isNodeGlobals) => {
60
- const trackMapItems = isNodeGlobals ? getNodeGlobals() : coreNodeModules
61
- const trackMap = {}
62
-
63
- for (const item of trackMapItems) {
64
- trackMap[item] = {
65
- [READ]: {
66
- name: item,
67
- },
68
- }
69
- }
70
-
71
- return trackMap
72
- }
73
-
74
- module.exports = {
75
- getRestrictedGlobals,
76
- createTrackMap,
77
- coreNodeModules,
78
- getNodeGlobals,
79
- }
package/license DELETED
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 ServiceNow Inc.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,26 +0,0 @@
1
- const { RuleTester } = require('eslint')
2
- const noPromise = require('../../lib/rules/no-promise')
3
-
4
- const ruleTester = new RuleTester({
5
- parserOptions: { ecmaVersion: 2015 },
6
- })
7
-
8
- const errorMessages = [{ message: 'ES2015 Promise class is not supported in now platform.' }]
9
-
10
- ruleTester.run('no-promise', noPromise, {
11
- valid: [
12
- {
13
- code: "const Promise = 'value';",
14
- },
15
- ],
16
- invalid: [
17
- {
18
- code: 'const p = new Promise()',
19
- errors: errorMessages,
20
- },
21
- {
22
- code: 'Promise.all()',
23
- errors: errorMessages,
24
- },
25
- ],
26
- })
@@ -1,60 +0,0 @@
1
- const { RuleTester } = require('eslint')
2
- const noUnsupportedNodeBuiltins = require('../../lib/rules/no-unsupported-node-builtins')
3
- const { coreNodeModules, getNodeGlobals } = require('../../lib/util/utility')
4
-
5
- const ruleTester = new RuleTester({
6
- parserOptions: { sourceType: 'module' },
7
- env: { node: true, es6: true },
8
- })
9
-
10
- const getInvalidsForNoUnsupportedNodeBuiltsRule = () => {
11
- const invalids = []
12
- const nodeGlobals = getNodeGlobals()
13
-
14
- for (const module of coreNodeModules) {
15
- invalids.push({
16
- code: `const ${module} = require('${module}')`,
17
- errors: [{ message: `The ${module} Node.js API is not supported in now platform.` }],
18
- })
19
- }
20
-
21
- for (const module of coreNodeModules) {
22
- invalids.push({
23
- code: `import ${module} from '${module}'`,
24
- errors: [{ message: `The ${module} Node.js API is not supported in now platform.` }],
25
- })
26
- }
27
-
28
- for (const global of nodeGlobals) {
29
- invalids.push({
30
- code: `const x = ${global}`,
31
- errors: [{ message: `The ${global} Node.js API is not supported in now platform.` }],
32
- })
33
- }
34
-
35
- return invalids
36
- }
37
-
38
- ruleTester.run('no-unsupported-node-builtins', noUnsupportedNodeBuiltins, {
39
- valid: [
40
- {
41
- code: "const fs = {'Dir':'cool'}; const x = fs.Dir",
42
- },
43
- {
44
- code: 'const fs = {readFileSync: function(){}}; fs.readFileSync()',
45
- },
46
- {
47
- code: 'const Buffer = {from: function(){}}; Buffer.from()',
48
- },
49
- {
50
- code: `const validFunction = () => {
51
- fetch("https://api.example.com/data")
52
- .then(response => response.json())
53
- .then(data => console.log(data))
54
- .catch(error => console.error('Error:', error));
55
- };
56
- validFunction();`,
57
- },
58
- ],
59
- invalid: getInvalidsForNoUnsupportedNodeBuiltsRule(),
60
- })