-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
6,726 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
/* eslint-env node */ | ||
const path = require("path"); | ||
const base = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
jest: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:lit/recommended", | ||
"plugin:security/recommended-legacy", | ||
"prettier", | ||
], | ||
globals: { | ||
Atomics: "readonly", | ||
SharedArrayBuffer: "readonly", | ||
require: true, | ||
module: true, | ||
process: true, | ||
}, | ||
ignorePatterns: ["build/", "coverage/", "dist/", "node_modules"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: "module", | ||
}, | ||
plugins: [ | ||
"@typescript-eslint", | ||
"no-unsanitized", | ||
"no-wildcard-postmessage", | ||
"prototype-pollution-security-rules", | ||
"scanjs-rules", | ||
"security", | ||
"sonarjs", | ||
"@benasher44/implicit-dependencies", | ||
], | ||
rules: { | ||
"no-lone-blocks": "error", | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/naming-convention": [ | ||
"error", | ||
{ | ||
// Prefer ES private fields to TS privates (by forbidding TS privates | ||
// that don't start with `#`). If your code triggers this lint, replace | ||
// the TS class property with an ES private. Eg, | ||
// `private readonly foo: number` becomes `readonly #foo: number`. | ||
// https://github.com/eslint/eslint/issues/15417 | ||
format: ["camelCase"], | ||
modifiers: ["private"], | ||
prefix: ["#"], | ||
selector: "memberLike", | ||
}, | ||
], | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
args: "none", | ||
varsIgnorePattern: "(^_.*)|(^UI$)|(^Reddit$)|(^Devvit$)", | ||
}, | ||
], | ||
"@typescript-eslint/explicit-function-return-type": "off", // enabled in overrides for ts files only | ||
|
||
// Security linting rules | ||
"security/detect-unsafe-regex": "error", | ||
"security/detect-buffer-noassert": "error", | ||
"security/detect-child-process": "error", | ||
"security/detect-disable-mustache-escape": "error", | ||
"security/detect-eval-with-expression": "error", | ||
"security/detect-no-csrf-before-method-override": "error", | ||
"security/detect-non-literal-fs-filename": "off", | ||
"security/detect-non-literal-regexp": "error", | ||
"security/detect-non-literal-require": "error", | ||
"security/detect-object-injection": "off", | ||
"security/detect-possible-timing-attacks": "error", | ||
"security/detect-pseudoRandomBytes": "error", | ||
"no-unsanitized/method": "error", | ||
"no-unsanitized/property": "error", | ||
|
||
// SonarJS - Code Smell Detection | ||
"sonarjs/no-collection-size-mischeck": "warn", | ||
"sonarjs/no-duplicated-branches": "warn", | ||
"sonarjs/no-gratuitous-expressions": "warn", | ||
"sonarjs/no-identical-functions": "warn", | ||
"sonarjs/no-nested-switch": "warn", | ||
"sonarjs/no-redundant-jump": "warn", | ||
"sonarjs/no-same-line-conditional": "warn", | ||
"sonarjs/no-small-switch": "warn", | ||
"sonarjs/no-unused-collection": "warn", | ||
"sonarjs/no-useless-catch": "warn", | ||
"sonarjs/prefer-immediate-return": "warn", | ||
"sonarjs/prefer-object-literal": "warn", | ||
"sonarjs/prefer-single-boolean-return": "warn", | ||
|
||
// SonarJS - Bug Detection | ||
"sonarjs/no-all-duplicated-branches": "warn", | ||
"sonarjs/no-empty-collection": "warn", | ||
"sonarjs/no-element-overwrite": "warn", | ||
"sonarjs/no-identical-conditions": "warn", | ||
"sonarjs/no-identical-expressions": "warn", | ||
"sonarjs/no-ignored-return": "warn", | ||
"sonarjs/no-one-iteration-loop": "warn", | ||
"sonarjs/no-use-of-empty-return-value": "warn", | ||
"sonarjs/non-existent-operator": "warn", | ||
|
||
// Disallow implicit dependencies | ||
"@benasher44/implicit-dependencies/no-implicit": [ | ||
"error", | ||
{ peer: true, dev: true }, | ||
], | ||
|
||
// Don't use 'any' (Note: implicit any is already disallowed in TS) | ||
"@typescript-eslint/no-explicit-any": [ | ||
"warn", | ||
{ fixToUnknown: true, ignoreRestArgs: true }, | ||
], | ||
|
||
eqeqeq: ["error", "always", { null: "ignore" }], | ||
}, | ||
overrides: [ | ||
{ | ||
// TypeScript-only rules. | ||
files: ["*.ts", "*.tsx", "*.cts", "*.mts"], | ||
rules: { | ||
"@typescript-eslint/no-misused-promises": ["error", {}], | ||
"@typescript-eslint/no-floating-promises": ["error", {}], | ||
"@typescript-eslint/explicit-function-return-type": [ | ||
"error", | ||
{ | ||
allowExpressions: true, | ||
allowedNames: [ | ||
"render", // Always returns a TemplateResult | ||
"styles", // Always returns a CSSResult or CSSResult[] | ||
], | ||
}, | ||
], | ||
"@typescript-eslint/consistent-type-imports": "warn", | ||
}, | ||
}, | ||
{ | ||
// Explicitly disable type-checking on these files. They're not covered by | ||
// most tsconfigs which causes typescript-eslint to fail. | ||
files: [ | ||
".eslintrc.cjs", | ||
"postcss.config.cjs", | ||
"tailwind.config.cjs", | ||
"vite*.config.js", | ||
"vitest.config.js", | ||
], | ||
parserOptions: { project: null }, | ||
}, | ||
], | ||
}; | ||
|
||
module.exports = { | ||
...base, | ||
parserOptions: { | ||
...base.parserOptions, | ||
project: path.join(__dirname, "tsconfig.json"), | ||
}, | ||
}; |
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,15 @@ | ||
## Description: | ||
|
||
## Issue(s): | ||
|
||
<!-- If there are existing issues that this PR addresses, reference all of them here --> | ||
|
||
## 🧪 Testing Steps / Validation | ||
|
||
<!-- add details on how this PR has been tested, include reproductions and screenshots where applicable --> | ||
|
||
## ✅ Checks | ||
|
||
<!-- Make sure your Pull Request passes the CI checks and do check the following fields as needed --> | ||
|
||
- [ ] Contributor License Agreement ([CLA](https://docs.google.com/forms/d/e/1FAIpQLScG6Bf3yqS05yWV0pbh5Q60AsaXP2mw35_i7ZA19_7jWNJKsg/viewform)) completed if not a Reddit employee |
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,130 +1,6 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
/node_modules/ | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
/dist/ | ||
/src/bundler/tsd.json | ||
/src/typescript/typescript.js | ||
/.idea/ |
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.18.2 |
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,2 @@ | ||
/dist/ | ||
/node_modules/ |
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 @@ | ||
{ | ||
"arrowParens": "always", | ||
"bracketSpacing": true, | ||
"jsxSingleQuote": false, | ||
"proseWrap": "preserve", | ||
"semi": true, | ||
"singleQuote": false, | ||
"trailingComma": "all" | ||
} |
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
Oops, something went wrong.