Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint and prettier #113

Merged
merged 4 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
out/
dist/
extract/
node_modules/
15 changes: 0 additions & 15 deletions .eslintrc

This file was deleted.

114 changes: 114 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
module.exports = {
root: true,
env: {
browser: false,
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018,
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': 'off',
'array-callback-return': 'error',
'brace-style': 'error',
camelcase: [
'error',
{
properties: 'never',
allow: ['^UNSAFE_'],
},
],
curly: ['error', 'all'],
'consistent-return': 'warn',
eqeqeq: [
'error',
'always',
{
null: 'ignore',
},
],
'no-console': 'error',
'no-lonely-if': 'error',
'no-multi-spaces': 'error',
'no-nested-ternary': 'error',
'no-restricted-globals': ['error', 'event'],
'no-restricted-properties': 'error',
'no-restricted-syntax': ['error', 'LabeledStatement', 'WithStatement'],
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^__',
},
],
'one-var': ['error', 'never'],
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: '*',
next: 'return',
},
{
blankLine: 'always',
prev: 'block-like',
next: '*',
},
],
'prefer-const': [
'error',
{
destructuring: 'all',
},
],
'prefer-rest-params': 'error',
},
overrides: [
{
files: ['**/*.ts', '**/*.tsx'],
extends: ['plugin:@typescript-eslint/recommended'],
rules: {
'consistent-return': 'off',
'array-callback-return': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-namespace': [
'error',
{
allowDeclarations: true,
},
],
'@typescript-eslint/no-unused-expressions': ['error'],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^__',
},
],
'@typescript-eslint/ban-types': 'warn',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/array-type': [
'error',
{
default: 'generic',
},
],
'@typescript-eslint/no-redeclare': 'error',
},
},
],
};
70 changes: 35 additions & 35 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const osxNotarize =
process.env.APPLE_PASSWORD &&
process.env.APPLE_TEAM_ID
? {
tool: "notarytool",
tool: 'notarytool',
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
Expand All @@ -14,37 +14,37 @@ const osxSign = osxNotarize ? {} : undefined;

if (!osxNotarize) {
console.log(
"Notarytool credentials not passed, skipping sign and notarize step for OSX."
'Notarytool credentials not passed, skipping sign and notarize step for OSX.',
);
}

module.exports = {
packagerConfig: {
icon: "./assets/logo",
executableName: "Replit",
icon: './assets/logo',
executableName: 'Replit',
osxSign,
osxNotarize,
asar: true,

// ignore development files like README, typescript sources, etc.
ignore: (path) => {
if (path === "") {
if (path === '') {
return false;
}

// dist folder is necessary for the app to run
if (path.startsWith("/dist")) {
if (path.startsWith('/dist')) {
return false;
}

// package.json is necessary for the app to run
if (path === "/package.json") {
if (path === '/package.json') {
return false;
}

// node_modules are necessary, but we have to strip binaries
if (path.includes("node_modules")) {
const ignoreNodeBinaries = "/node_modules/\\.bin($|/)";
if (path.includes('node_modules')) {
const ignoreNodeBinaries = '/node_modules/\\.bin($|/)';
return path.match(ignoreNodeBinaries);
}

Expand All @@ -54,69 +54,69 @@ module.exports = {

protocols: [
{
name: "Replit",
schemes: ["replit"],
name: 'Replit',
schemes: ['replit'],
},
],
},
rebuildConfig: {},
hooks: {
generateAssets: async () => {
const cpy = (await import("cpy")).default;
await cpy("assets", "dist");
const cpy = (await import('cpy')).default;
await cpy('assets', 'dist');
},
},
makers: [
{
name: "@electron-forge/maker-squirrel",
name: '@electron-forge/maker-squirrel',
config: {
setupIcon: "./assets/logo.ico",
iconUrl: "https://replit.com/public/images/logo.ico",
setupIcon: './assets/logo.ico',
iconUrl: 'https://replit.com/public/images/logo.ico',
certificateFile: process.env.WINDOWS_CERTIFICATE_FILE,
certificatePassword: process.env.WINDOWS_CERTIFICATE_PASSWORD,
},
},
{
name: "@electron-forge/maker-dmg",
name: '@electron-forge/maker-dmg',
config: {
name: "Replit",
icon: "./assets/logo.icns",
name: 'Replit',
icon: './assets/logo.icns',
overwrite: true,
additionalDMGOptions: {
"background-color": "#0E1525",
'background-color': '#0E1525',
},
},
},
{
name: "@electron-forge/maker-deb",
name: '@electron-forge/maker-deb',
config: {
options: {
name: "replit",
bin: "Replit",
productName: "Replit",
maintainer: "Replit",
mimeType: ["x-scheme-handler/replit"],
homepage: "https://replit.com",
description: "Replit desktop app",
icon: "./assets/logo.png",
categories: ["Development"],
section: "devel",
name: 'replit',
bin: 'Replit',
productName: 'Replit',
maintainer: 'Replit',
mimeType: ['x-scheme-handler/replit'],
homepage: 'https://replit.com',
description: 'Replit desktop app',
icon: './assets/logo.png',
categories: ['Development'],
section: 'devel',
},
},
},
{
name: "@electron-forge/maker-zip",
name: '@electron-forge/maker-zip',
config: {},
},
],
publishers: [
{
name: "@electron-forge/publisher-github",
name: '@electron-forge/publisher-github',
authToken: process.env.GH_TOKEN,
config: {
repository: {
owner: "replit",
name: "desktop",
owner: 'replit',
name: 'desktop',
},
},
},
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "rimraf dist && esbuild src/main.ts src/preload.ts --target=es2015 --platform=node --format=cjs --packages=external --minify --bundle --outdir=dist",
"ts:check": "tsc --noEmit",
"ts:watch": "tsc --noEmit -w",
"lint": "eslint -c .eslintrc --ext .ts ./src",
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
"ci": "npm-run-all --parallel build ts:check lint",
"start": "pnpm build && electron-forge start",
"start:local": "pnpm build && cross-env REPLIT_URL=http://localhost:3000 electron-forge start",
Expand All @@ -23,13 +23,18 @@
"engines": {
"pnpm": "8.5.1"
},
"prettier": {
"trailingComma": "all",
"singleQuote": true
},
"devDependencies": {
"@electron-forge/cli": "^6.1.0",
"@electron-forge/maker-deb": "^6.0.5",
"@electron-forge/maker-dmg": "^6.1.0",
"@electron-forge/maker-squirrel": "^6.0.5",
"@electron-forge/maker-zip": "^6.0.5",
"@electron-forge/publisher-github": "^6.1.1",
"@types/eslint": "^8.44.2",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
Expand All @@ -39,7 +44,10 @@
"electron-winstaller": "^5.1.0",
"esbuild": "^0.18.6",
"eslint": "^7.32.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.2",
"rimraf": "^5.0.1",
"typescript": "^4.9.5"
},
Expand Down
Loading