Skip to content

Commit

Permalink
feat: add prettier and update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
fruneen committed Dec 17, 2024
1 parent 96d78ec commit 5280139
Show file tree
Hide file tree
Showing 25 changed files with 573 additions and 423 deletions.
111 changes: 95 additions & 16 deletions packages/create-ship-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,106 @@
module.exports = {
plugins: ['@typescript-eslint'],
extends: ['airbnb', 'airbnb-typescript'],
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'airbnb', 'airbnb-typescript', 'prettier'],
plugins: ['@typescript-eslint', 'import', 'simple-import-sort', 'no-relative-import-paths'],
ignorePatterns: ['.eslintrc.js'],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
ecmaVersion: 13,
ecmaVersion: 14,
sourceType: 'module',
},
env: {
node: true,
},
rules: {
'@typescript-eslint/no-use-before-define': 'off',
'react/function-component-definition': 'off',
'import/no-extraneous-dependencies': 'off',
'react/jsx-props-no-spreading': 'off',
'react/require-default-props': 'off',
'import/prefer-default-export': 'off',
'object-curly-newline': 'off',
'no-console': 'off',

'no-relative-import-paths/no-relative-import-paths': [
'warn',
{
allowSameFolder: true,
allowedDepth: 1,
rootDir: './src',
prefix: '',
},
],

// Too strict
'no-param-reassign': 'off',
'max-classes-per-file': 'off',
'no-underscore-dangle': 'off',
'class-methods-use-this': 'off',
'no-plusplus': 'off',
'max-len': ['warn', {
code: 120,
ignoreStrings: true,
ignoreUrls: true,
}],

'global-require': 'off',

// https://stackoverflow.com/a/64024916/286387
'no-use-before-define': 'off',
// Allow for..of syntax
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
// https://basarat.gitbook.io/typescript/main-1/defaultisbad
'import/prefer-default-export': 'off',
'import/no-default-export': 'off',
'import/no-anonymous-default-export': 'off',
// It's not accurate in the monorepo style
'import/no-extraneous-dependencies': 'off',
'import/extensions': 'off',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',

// Allow most functions to rely on type inference.
// If the function is exported, then `@typescript-eslint/explicit-module-boundary-types` will ensure it's typed.
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false,
classes: true,
variables: true,
typedefs: true,
},
],

'@typescript-eslint/no-explicit-any': 'error',

// Enable some rules for async JS
'no-promise-executor-return': 'error',
'max-nested-callbacks': 'error',
'no-return-await': 'error',
},
overrides: [
{
files: ['*.js', '*.ts'],
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// Third-party libraries and frameworks
['^@?\\w'],
// Internal app modules
['^helpers', '^installers', '^utils', '^routes'],
// App config file
['^config'],
// Internal packages
['^types', '^app.constants'],
// Relative imports
['^\\.\\.(?!/?$)', '^\\.\\./?$', '^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Side effect imports.
['^\\u0000'],
],
},
],
},
},
{
files: ['**/types.ts'],
rules: {
'no-restricted-imports': 'off',
},
},
],
};
31 changes: 31 additions & 0 deletions packages/create-ship-app/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/dist

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# lock file
pnpm-lock.yaml

# local env files
.env*.local

# typescript
*.tsbuildinfo

.prettierignore
4 changes: 4 additions & 0 deletions packages/create-ship-app/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"singleQuote": true
}
6 changes: 3 additions & 3 deletions packages/create-ship-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ We believe we could ship great products faster, while maintain decent quality an

## Core concepts

* We automatically build ship out of the number of smaller components. Our ultimate goal is too keep only parts your need for your product development.
* Every component is kept is tiny as possible to simplify maintenance and stay up to date with new releases.
* Ship is always in a production-ready state. We test every release manually to make sure great developer experience. We use ship to build our products, see more [here](https://www.paralect.com/build-stage).
- We automatically build ship out of the number of smaller components. Our ultimate goal is too keep only parts your need for your product development.
- Every component is kept is tiny as possible to simplify maintenance and stay up to date with new releases.
- Ship is always in a production-ready state. We test every release manually to make sure great developer experience. We use ship to build our products, see more [here](https://www.paralect.com/build-stage).

## License

Expand Down
25 changes: 20 additions & 5 deletions packages/create-ship-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"build": "tsup",
"dev": "tsup --onSuccess \"node dist/index.js\"",
"dev:create-resource": "tsup --onSuccess \"node dist/index.js create resource fly\"",
"tsc": "tsc --noEmit --watch",
"prettier": "prettier . --write --config .prettierrc.json",
"eslint": "eslint . --fix",
"precommit": "lint-staged"
},
"devDependencies": {
Expand All @@ -35,23 +38,30 @@
"@types/prompts": "2.0.1",
"@types/tar": "6.1.5",
"@types/validate-npm-package-name": "3.0.0",
"@typescript-eslint/eslint-plugin": "6.7.0",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"async-retry": "1.3.1",
"commander": "2.20.0",
"commander": "12.1.0",
"conf": "10.2.0",
"cross-spawn": "7.0.6",
"dotenv": "16.3.1",
"eslint": "8.49.0",
"eslint": "8.56.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-typescript": "17.1.0",
"got": "14.4.5",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-no-relative-import-paths": "1.5.5",
"eslint-plugin-simple-import-sort": "10.0.0",
"got": "11.8.6",
"gradient-string": "2.0.2",
"lint-staged": "14.0.1",
"picocolors": "1.0.0",
"pluralize": "8.0.0",
"prettier": "3.4.2",
"prompts": "2.1.0",
"tar": "7.4.3",
"tsup": "8.3.5",
"typescript": "5.2.2",
"update-check": "1.5.4",
"validate-npm-package-name": "3.0.0"
},
Expand All @@ -63,7 +73,12 @@
},
"lint-staged": {
"*.ts": [
"eslint --ext ts --fix"
"eslint --fix",
"bash -c 'tsc --noEmit'",
"prettier --write"
],
"!*.ts": [
"prettier --write"
]
},
"engines": {
Expand Down
Loading

0 comments on commit 5280139

Please sign in to comment.