Skip to content

Commit

Permalink
[workspace] Imported shared config packages
Browse files Browse the repository at this point in the history
  • Loading branch information
hardsetting committed Jul 17, 2023
1 parent c195aea commit cfeb8fd
Show file tree
Hide file tree
Showing 16 changed files with 4,239 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

node_modules
**/node_modules/
coverage
**/coverage
build
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.yarn-integrity
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.zip

# Xcode
#
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
apps/mobile/xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
apps/mobile/.idea
apps/mobile/.gradle
apps/mobile/local.properties
*.iml
*.hprof

# BUCK
apps/mobile/buck-out/
apps/mobile/.buckd/
*.keystore
apps/mobile/!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
apps/mobile/*.jsbundle

# Ruby / CocoaPods
apps/mobile/ios/Pods/
apps/mobile/vendor/bundle/

# Turborepo
.turbo
**/.turbo
.next/**
**/*.log
**/out/

# Webpack profiler
stats.json
apps/extension/dist

# JetBrains IDE
.idea

# Playwright
test-results
playwright-report
e2e/.cache

# eslint
.eslintcache

# typescript
*.tsbuildinfo

dist/
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Identity Connect Docs

This is a public repository for Identity Connect, that will contain docs, examples and source code for the SDKs.

This monorepo uses `turborepo`.

## Getting started

1. Install `node.js`
2. Clone the repo
3. run `yarn install` from the root directory

## Packages

- `eslint-config`: `eslint` configurations
- `tsconfig`: `tsconfig.json`s used throughout the monorepo

37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "identity-connect-docs",
"version": "0.0.0",
"private": true,
"workspaces": {
"packages": [
"examples/*",
"packages/*"
]
},
"scripts": {
"build": "turbo run build",
"lint": "turbo run lint",
"lint:fix": "turbo run lint:fix",
"test": "turbo run test",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
},
"devDependencies": {
"@identity-connect/eslint-config": "*",
"@identity-connect/eslint-plugin": "*",
"dotenv": "^16.0.3",
"eslint": "^8.21.0",
"prettier": "latest",
"syncpack": "^8.4.11",
"turbo": "latest",
"typescript": "5.0.4"
},
"engines": {
"npm": ">=7.0.0",
"node": ">=14.0.0"
},
"packageManager": "[email protected]",
"resolutions": {
"typescript": "5.0.4"
},
"prettier": "@identity-connect/prettier-config"
}
76 changes: 76 additions & 0 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

module.exports = {
env: {
es2021: true,
jest: true,
},
extends: ['airbnb', 'airbnb-typescript', 'plugin:typescript-sort-keys/recommended'],
ignorePatterns: ['dist/**/*', '*.css', '*.jsx'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: ['tsconfig.json', 'tsconfig.build.json'],
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: [
'@identity-connect',
'@typescript-eslint',
'react',
'react-hooks',
'sort-class-members',
'sort-destructure-keys',
'sort-keys-fix',
'header',
],
rules: {
'@typescript-eslint/brace-style': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variableLike',
modifiers: ['unused'],
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
},
],
'@typescript-eslint/no-use-before-define': 'off',
// allow unused variables that start with an underscore
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
'function-paren-newline': 'off',
'header/header': [2, 'line', [' Copyright © Aptos', ' SPDX-License-Identifier: Apache-2.0'], 2],
'implicit-arrow-linebreak': 'off',
'import/prefer-default-export': 'off',
'max-classes-per-file': 'off',
'max-len': ['error', { code: 120 }],
'no-confusing-arrow': 'off',
'no-continue': 'off',
// Replacing airbnb rule with following, to re-enable 'ForOfStatement'
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
'no-underscore-dangle': 'off',
// Allow prepending statements with void to explicitly ignore the return value
'no-void': ['error', { allowAsStatement: true }],
'object-curly-newline': 'off',
'operator-linebreak': 'off',
'react/require-default-props': 0,
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react/jsx-closing-tag-location': 'off',
'react/jsx-curly-newline': 'off',
'react/jsx-indent': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/jsx-props-no-spreading': 'off',
'react/jsx-wrap-multilines': 'off',
'sort-destructure-keys/sort-destructure-keys': 2,
'sort-keys-fix/sort-keys-fix': 'warn',
'sort-keys': ['error', 'asc', { caseSensitive: true, minKeys: 2, natural: false }],
'newline-per-chained-call': ['off'],
},
};
25 changes: 25 additions & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@identity-connect/eslint-config",
"version": "0.0.0",
"private": true,
"main": "index.js",
"dependencies": {
"@identity-connect/eslint-plugin": "*",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"eslint": "^8.33.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-sort-class-members": "^1.14.1",
"eslint-plugin-sort-destructure-keys": "^1.4.0",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-typescript-sort-keys": "^2.3.0",
"typescript": "5.0.4"
}
}
8 changes: 8 additions & 0 deletions packages/eslint-plugin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

module.exports = {
rules: {
'no-client-date': require('./rules/no-client-date'),
},
};
15 changes: 15 additions & 0 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@identity-connect/eslint-plugin",
"version": "0.0.0",
"private": true,
"main": "index.js",
"scripts": {
"test": "jest"
},
"peerDependencies": {
"eslint": "^8.33.0"
},
"devDependencies": {
"jest": "^29.5.0"
}
}
43 changes: 43 additions & 0 deletions packages/eslint-plugin/rules/no-client-date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Use server time instead of client time',
},
fixable: 'code',
messages: {
dateNow: 'Use getServerTime() instead of Date.now().',
newDate: 'Use getServerDate() instead of new Date().',
},
},
create(context) {
return {
CallExpression(node) {
const { object, property } = node.callee;
if (object?.name === 'Date' && property?.name === 'now') {
context.report({
node,
messageId: 'dateNow',
fix: (fixer) => {
return fixer.replaceText(node, 'getServerTime()');
},
});
}
},
NewExpression(node) {
if (node.callee.name === 'Date' && node.arguments.length === 0) {
context.report({
node,
messageId: 'newDate',
fix: (fixer) => {
return fixer.replaceText(node, 'getServerDate()');
},
});
}
},
};
},
};
32 changes: 32 additions & 0 deletions packages/eslint-plugin/rules/no-client-date.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

const { RuleTester } = require('eslint');
const noClientDateRule = require('./no-client-date');

const ruleTester = new RuleTester();
ruleTester.run('no-client-date', noClientDateRule, {
valid: [
{
code: 'getServerDate()',
},
{
code: 'getServerTime()',
},
{
code: 'new Date(timestamp)',
},
],
invalid: [
{
code: 'Date.now()',
errors: [{ messageId: 'dateNow' }],
output: 'getServerTime()',
},
{
code: 'new Date()',
errors: [{ messageId: 'newDate' }],
output: 'getServerDate()',
},
],
});
6 changes: 6 additions & 0 deletions packages/prettier-config/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
}
6 changes: 6 additions & 0 deletions packages/prettier-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@identity-connect/prettier-config",
"version": "0.0.0",
"private": true,
"main": "index.json"
}
3 changes: 3 additions & 0 deletions packages/tsconfig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# `tsconfig`

These are base shared `tsconfig.json`s from which all other `tsconfig.json`'s inherit from.
18 changes: 18 additions & 0 deletions packages/tsconfig/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"strict": true,
"target": "es2021",
"lib": [
"es2021"
],
"module": "esnext",
"moduleResolution": "node",
"isolatedModules": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"noEmitOnError": true
}
}
Loading

0 comments on commit cfeb8fd

Please sign in to comment.