Skip to content

Commit

Permalink
add no-restricted-imports rule for workflows in samples to disallow i…
Browse files Browse the repository at this point in the history
…mporting node built-ins (temporalio#133)

* add no-restricted-imports rule for workflows in samples to disallow importing node built-ins

Fix temporalio#106

* Prettier

* use `module.builtinModules` instead of hard-coded list

Co-authored-by: Loren 🤓 <[email protected]>
  • Loading branch information
vkarpov15 and lorensr authored Apr 20, 2022
1 parent fb38b50 commit 5275d91
Show file tree
Hide file tree
Showing 26 changed files with 390 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .shared/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions activities-cancellation-heartbeating/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions activities-dependency-injection/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions activities-examples/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions activities-sticky-queues/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions child-workflows/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions continue-as-new/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions cron-workflows/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions dsl-interpreter/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions ejson/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions encryption/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions expense/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions grpc-calls/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions hello-world-mtls/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions hello-world/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
15 changes: 15 additions & 0 deletions instrumentation/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const { builtinModules } = require('module');

const ALLOWED_NODE_BUILTINS = new Set(['assert']);

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -30,4 +34,15 @@ module.exports = {
],
'@typescript-eslint/no-explicit-any': 'off',
},
overrides: [
{
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
rules: {
'no-restricted-imports': [
'error',
...builtinModules.filter(m => !ALLOWED_NODE_BUILTINS.has(m)).flatMap(m => [m, `node:${m}`])
],
},
},
],
};
Loading

0 comments on commit 5275d91

Please sign in to comment.