-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kangrui Johann Ye <[email protected]>
- Loading branch information
1 parent
8f77e07
commit 7c5a549
Showing
15 changed files
with
198 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {TSESLint} from '@typescript-eslint/utils'; | ||
|
||
export const nodeRules: TSESLint.Linter.RulesRecord = { | ||
// require all requires be top-level | ||
'node/global-require': 'error', | ||
|
||
// allow typescript files | ||
'node/no-missing-import': [ | ||
'error', | ||
{ | ||
tryExtensions: ['.js', '.ts', '.json', '.node'], | ||
}, | ||
], | ||
|
||
// disallow use of new operator with the require function | ||
'node/no-new-require': 'error', | ||
|
||
// disallow string concatenation with __dirname and __filename | ||
'node/no-path-concat': 'error', | ||
|
||
// disallow use of synchronous methods (off by default) | ||
'node/no-sync': 'error', | ||
|
||
// we use typescript, which transpiles es-syntax to cjs-syntax | ||
'node/no-unsupported-features/es-syntax': 'off', | ||
|
||
// we use typescript, so node-builtins are typed and checked via TS | ||
'node/no-unsupported-features/node-builtins': 'off', | ||
}; |
37 changes: 0 additions & 37 deletions
37
packages/eslint-plugin-node/src/configs/recommended/recommended.config.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {TSESLint} from '@typescript-eslint/utils'; | ||
import pluginSecurity from 'eslint-plugin-security'; | ||
|
||
const recommendedRules = pluginSecurity.configs.recommended.rules; | ||
const updatedRules = Object.entries<TSESLint.Linter.RuleEntry>(recommendedRules) | ||
.map(([key, value]) => [key, warningEntryToError(value)]); | ||
|
||
// yes, we know this works correctly | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
export const securityRules = Object.fromEntries(updatedRules) as TSESLint.Linter.RulesRecord; | ||
|
||
function warningEntryToError(value: TSESLint.Linter.RuleEntry): TSESLint.Linter.RuleEntry { | ||
const level = Array.isArray(value) ? value[0] : value; | ||
const updatedLevel = warningLevelToError(level); | ||
|
||
return Array.isArray(value) ? [updatedLevel, value.slice(1)] : updatedLevel; | ||
} | ||
|
||
function warningLevelToError(level: TSESLint.Linter.RuleLevel): TSESLint.Linter.RuleLevel { | ||
if (level === 'warn') { | ||
return 'error'; | ||
} else if (level === 1) { | ||
return 'error'; | ||
} | ||
|
||
return level; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,22 @@ | ||
export {configs} from './configs'; | ||
export {rules} from './rules'; | ||
import tseslint from 'typescript-eslint'; | ||
import { cloudflightTypescriptConfig } from '@cloudflight/eslint-plugin-typescript'; | ||
import nounsanitized from 'eslint-plugin-no-unsanitized'; | ||
import pluginSecurity from 'eslint-plugin-security'; | ||
import {securityRules} from './configs/security'; | ||
|
||
export const cloudflightNodeConfig = tseslint.config( | ||
...cloudflightTypescriptConfig, | ||
{ | ||
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'], | ||
extends: [ | ||
...cloudflightTypescriptConfig, | ||
nounsanitized.configs.recommended, | ||
pluginSecurity.configs.recommended, | ||
], | ||
rules: { | ||
// todo: eslint-plugin-node has not been migrated to support v9 yet | ||
// ...nodeRules, | ||
...securityRules, | ||
} | ||
}, | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Linter } from 'eslint'; | ||
|
||
declare const nounsanitized: { | ||
readonly configs: { | ||
readonly recommended: { readonly rules: Readonly<Linter.RulesRecord> }; | ||
}; | ||
}; | ||
|
||
export = nounsanitized; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@types/eslint-plugin-no-unsanitized", | ||
"version": "0.1.0", | ||
"description": "TypeScript definitions for eslint-plugin-no-unsanitized", | ||
"homepage": "https://github.com/cloudflightio/cloudflight-eslint-plugin", | ||
"bugs": { | ||
"url": "https://github.com/cloudflightio/cloudflight-eslint-plugin/issues" | ||
}, | ||
"private": true, | ||
"author": "Cloudflight GmbH", | ||
"license": "Apache-2.0", | ||
"main": "", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@types/eslint": "*" | ||
}, | ||
"typeScriptVersion": "4.5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Linter } from 'eslint'; | ||
|
||
declare const pluginSecurity: { | ||
readonly configs: { | ||
readonly recommended: { readonly rules: Readonly<Linter.RulesRecord> }; | ||
}; | ||
}; | ||
|
||
export = pluginSecurity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@types/eslint-plugin-security", | ||
"version": "0.1.0", | ||
"description": "TypeScript definitions for eslint-plugin-security", | ||
"homepage": "https://github.com/cloudflightio/cloudflight-eslint-plugin", | ||
"bugs": { | ||
"url": "https://github.com/cloudflightio/cloudflight-eslint-plugin/issues" | ||
}, | ||
"private": true, | ||
"author": "Cloudflight GmbH", | ||
"license": "Apache-2.0", | ||
"main": "", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@types/eslint": "*" | ||
}, | ||
"typeScriptVersion": "4.5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters