Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
[chore] Setup TypeScript (#1)
Browse files Browse the repository at this point in the history
* Setup yarn v3

* Install React packages

* Create .editorconfig

* Setup ESLint
  • Loading branch information
AsPulse authored Mar 4, 2023
1 parent 1d77995 commit 51c09a9
Show file tree
Hide file tree
Showing 9 changed files with 3,271 additions and 99 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
107 changes: 107 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
],
overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json',
},
plugins: [
'react',
'@typescript-eslint',
'import',
'unused-imports',
],
settings: {
react: {
version: 'detect',
},
},
rules: {

/* Code Styles */
'indent': [ 'error', 2 ],
'linebreak-style': [ 'error', 'unix' ],
'quotes': [ 'error', 'single' ],
'jsx-quotes': [ 'error', 'prefer-single' ],
'semi': [ 'error', 'always' ],
'comma-dangle': [ 'error', 'always-multiline' ],
'no-trailing-spaces': [ 'error' ],
'camelcase': [ 'error' ],
'object-curly-spacing': [ 'error', 'always' ],
'array-bracket-spacing': [ 'error', 'always', { arraysInArrays: false, objectsInArrays: false }],
'space-before-blocks': [ 'error', 'always' ],
'spaced-comment': [ 'error', 'always' ],
'brace-style': [ 'error', '1tbs', { allowSingleLine: true }],
'arrow-spacing': [ 'error', { before: true, after: true }],
'func-call-spacing': [ 'error', 'never' ],
'function-call-argument-newline': [ 'error', 'consistent' ],
'dot-location': [ 'error', 'property' ],
'dot-notation': [ 'error' ],
'@typescript-eslint/array-type': [ 'error', 'array-simple' ],
'@typescript-eslint/prefer-for-of': [ 'error' ],
'@typescript-eslint/prefer-includes': [ 'error' ],

// This enable the TypeScript compiler to perform the type processing s in a lightweight.
'@typescript-eslint/explicit-function-return-type': [ 'error' ],

// RegExp#exec may also be slightly faster than String#match.
'@typescript-eslint/prefer-regexp-exec': [ 'error' ],

/* import and export */
'no-restricted-exports': [ 'error', { restrictDefaultExports: { direct: true, defaultFrom: true, namedFrom: true } }],
'@typescript-eslint/consistent-type-imports': [ 'error', { prefer: 'type-imports', fixStyle: 'separate-type-imports' }],
'@typescript-eslint/no-require-imports': [ 'error' ],
'import/consistent-type-specifier-style': [ 'error', 'prefer-top-level' ],
'import/no-absolute-path': [ 'error' ],
'import/no-empty-named-blocks': [ 'error' ],
'import/no-duplicates': [ 'error' ],
'import/no-cycle': [ 'error' ],
'unused-imports/no-unused-imports': [ 'error' ],

/* Maintainability */
'complexity': [ 'warn', 6 ],
'max-classes-per-file': [ 'warn', 1 ],
'max-depth': [ 'warn', 3 ],
'max-len': [ 'warn', { code: 50, ignoreComments: true, ignoreStrings: true, ignoreTemplateLiterals: true }],
'max-lines-per-function': [ 'warn', 50 ],
'no-multi-str': [ 'warn' ],
'object-shorthand': [ 'warn' ],
'prefer-template': [ 'warn' ],
'@typescript-eslint/explicit-member-accessibility': [ 'error', { overrides: { constructors: 'off' } }],
'@typescript-eslint/no-redundant-type-constituents': [ 'error' ],

/* Best Practices */
'no-console': [ 'warn' ],
'no-alert': [ 'error' ],
'no-eval': [ 'error' ],
'no-var': [ 'error' ],
'radix': [ 'error' ],
'require-await': [ 'error' ],
'no-constructor-return': [ 'error' ],
'no-promise-executor-return': [ 'error' ],
'no-self-compare': [ 'error' ],
'no-unmodified-loop-condition': [ 'error' ],
'no-unused-private-class-members': [ 'error' ],
'no-use-before-define': [ 'error' ],
'no-param-reassign': [ 'error' ],
'no-return-assign': [ 'error' ],
'no-return-await': [ 'error' ],
'eqeqeq': [ 'error', 'always' ],
'prefer-const': [ 'warn' ],

},
};
113 changes: 14 additions & 99 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,19 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# 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
#dependencies
node_modules

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
#yarn v3
.yarn/*
!.yarn/releases
!.yarn/plugins

# Bower dependency directory (https://bower.io/)
bower_components
#build artifacts
dist/

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
#logs and caches
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# 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 variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# 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

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
#misc
.DS_Store
873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.4.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarnPath: .yarn/releases/yarn-3.4.1.cjs
nodeLinker: node-modules
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "sugarform",
"version": "1.0.0",
"main": "dist/cjs/index.js",
"repository": "https://github.com/sugarform-dev/sugarform.git",
"author": "aspulse <[email protected]>",
"license": "MIT",
"packageManager": "[email protected]",
"devDependencies": {
"@types/react": "^18.0.28",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"eslint": "^8.35.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-unused-imports": "^2.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.5"
},
"peerDependencies": {
"@types/react": "^17.0.0 || ^18.0.0",
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
}
Empty file added src/index.ts
Empty file.
32 changes: 32 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"compilerOptions": {
"target": "ES5",
"module": "ESNext",
"outDir": "dist",
"rootDir": "./src",

"jsx": "react",
"sourceMap": true,
"declaration": true,
"declarationDir": "types",
"declarationMap": true,

"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,

"esModuleInterop": true,
"emitDeclarationOnly": true,
"skipLibCheck": false,

"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true
},
"include": ["src", ".eslintrc.cjs"],
"exclude": ["node_modules", "dist"]
}
Loading

0 comments on commit 51c09a9

Please sign in to comment.