Skip to content

Commit 0462298

Browse files
committed
🚀SD-Coding-Standards
0 parents  commit 0462298

File tree

13 files changed

+7169
-0
lines changed

13 files changed

+7169
-0
lines changed

‎.eslintrc.js‎

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
es2021: true,
6+
node: true,
7+
},
8+
extends: [
9+
'eslint:recommended',
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:react/recommended',
12+
'plugin:react-hooks/recommended',
13+
'plugin:jsx-a11y/recommended',
14+
'plugin:import/recommended',
15+
'plugin:import/typescript',
16+
'plugin:tailwindcss/recommended',
17+
'next/core-web-vitals',
18+
'prettier', // Make sure this is last to override other configs
19+
],
20+
parser: '@typescript-eslint/parser',
21+
parserOptions: {
22+
ecmaFeatures: {
23+
jsx: true,
24+
},
25+
ecmaVersion: 2021,
26+
sourceType: 'module',
27+
project: './tsconfig.json',
28+
},
29+
plugins: [
30+
'@typescript-eslint',
31+
'react',
32+
'react-hooks',
33+
'import',
34+
'jsx-a11y',
35+
'tailwindcss',
36+
],
37+
settings: {
38+
react: {
39+
version: 'detect',
40+
},
41+
'import/resolver': {
42+
typescript: {},
43+
node: {
44+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
45+
},
46+
},
47+
},
48+
rules: {
49+
// React rules
50+
'react/react-in-jsx-scope': 'off', // Not needed in Next.js
51+
'react/prop-types': 'off', // Use TypeScript for prop validation
52+
'react/jsx-filename-extension': [1, { extensions: ['.tsx', '.jsx'] }],
53+
'react/jsx-props-no-spreading': 'off', // Allow JSX props spreading
54+
'react/jsx-sort-props': [
55+
'warn',
56+
{
57+
callbacksLast: true,
58+
shorthandFirst: true,
59+
ignoreCase: true,
60+
reservedFirst: true,
61+
},
62+
],
63+
64+
// TypeScript rules
65+
'@typescript-eslint/explicit-module-boundary-types': 'off', // Let TypeScript infer return types
66+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
67+
'@typescript-eslint/no-explicit-any': 'warn',
68+
'@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports' }],
69+
'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
70+
71+
// Import rules
72+
'import/order': [
73+
'warn',
74+
{
75+
groups: [
76+
'builtin', // Node.js built-in modules
77+
'external', // npm packages
78+
'internal', // Absolute imports
79+
['parent', 'sibling'], // Relative imports
80+
'index', // index imports
81+
'object', // object imports
82+
'type', // type imports
83+
],
84+
'newlines-between': 'always',
85+
alphabetize: {
86+
order: 'asc',
87+
caseInsensitive: true,
88+
},
89+
pathGroups: [
90+
{
91+
pattern: 'react',
92+
group: 'builtin',
93+
position: 'before',
94+
},
95+
{
96+
pattern: 'next/**',
97+
group: 'builtin',
98+
position: 'after',
99+
},
100+
{
101+
pattern: '@/**',
102+
group: 'internal',
103+
position: 'after',
104+
},
105+
],
106+
pathGroupsExcludedImportTypes: ['react'],
107+
},
108+
],
109+
'import/no-duplicates': 'error',
110+
111+
// General rules
112+
'no-console': ['warn', { allow: ['warn', 'error'] }],
113+
'prefer-const': 'error',
114+
'no-nested-ternary': 'warn',
115+
116+
// Tailwind rules
117+
'tailwindcss/no-custom-classname': 'warn',
118+
'tailwindcss/classnames-order': 'warn',
119+
},
120+
overrides: [
121+
// Override rules for specific file patterns
122+
{
123+
files: ['*.js', '*.jsx', '*.ts', '*.tsx'],
124+
rules: {
125+
'import/no-anonymous-default-export': 'warn',
126+
},
127+
},
128+
{
129+
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
130+
extends: ['plugin:testing-library/react'],
131+
rules: {
132+
'import/no-extraneous-dependencies': 'off',
133+
},
134+
},
135+
],
136+
};

‎.github/workflows/ci.yml‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '18'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Lint
26+
run: npm run lint
27+
28+
- name: Type check
29+
run: npm run type-check
30+
31+
format:
32+
name: Format Check
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v3
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: '18'
41+
cache: 'npm'
42+
43+
- name: Install dependencies
44+
run: npm ci
45+
46+
- name: Check formatting
47+
run: npx prettier --check "**/*.{js,jsx,ts,tsx,json,md}"

‎.prettierrc.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
semi: true,
3+
singleQuote: true,
4+
tabWidth: 2,
5+
printWidth: 100,
6+
trailingComma: 'es5',
7+
arrowParens: 'always',
8+
endOfLine: 'lf',
9+
bracketSpacing: true,
10+
bracketSameLine: false,
11+
plugins: ['prettier-plugin-tailwindcss'],
12+
tailwindConfig: './tailwind.config.js',
13+
tailwindFunctions: ['clsx', 'cn', 'cva'],
14+
// Sort Tailwind CSS classes according to recommended order
15+
tailwindAttributes: ['className', 'tw', 'class'],
16+
};

‎.vscode/extensions.json‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"esbenp.prettier-vscode",
5+
"bradlc.vscode-tailwindcss",
6+
"formulahendry.auto-rename-tag",
7+
"streetsidesoftware.code-spell-checker",
8+
"naumovs.color-highlight",
9+
"mikestead.dotenv",
10+
"dsznajder.es7-react-js-snippets",
11+
"wix.vscode-import-cost",
12+
"yoavbls.pretty-ts-errors"
13+
]
14+
}

‎.vscode/settings.json‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"editor.codeActionsOnSave": {
5+
"source.fixAll.eslint": "explicit",
6+
"source.organizeImports": "never"
7+
},
8+
"editor.rulers": [100],
9+
"editor.tabSize": 2,
10+
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
11+
"typescript.tsdk": "node_modules/typescript/lib",
12+
"typescript.enablePromptUseWorkspaceTsdk": true,
13+
"files.eol": "\n",
14+
"files.insertFinalNewline": true,
15+
"files.trimTrailingWhitespace": true,
16+
"[javascript]": {
17+
"editor.defaultFormatter": "esbenp.prettier-vscode"
18+
},
19+
"[javascriptreact]": {
20+
"editor.defaultFormatter": "esbenp.prettier-vscode"
21+
},
22+
"[typescript]": {
23+
"editor.defaultFormatter": "esbenp.prettier-vscode"
24+
},
25+
"[typescriptreact]": {
26+
"editor.defaultFormatter": "esbenp.prettier-vscode"
27+
},
28+
"[json]": {
29+
"editor.defaultFormatter": "esbenp.prettier-vscode"
30+
},
31+
"[markdown]": {
32+
"editor.defaultFormatter": "esbenp.prettier-vscode"
33+
},
34+
"tailwindCSS.includeLanguages": {
35+
"typescript": "javascript",
36+
"typescriptreact": "javascript"
37+
},
38+
"tailwindCSS.experimental.classRegex": [
39+
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
40+
["cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
41+
["clsx\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
42+
],
43+
"css.lint.unknownAtRules": "ignore",
44+
"editor.quickSuggestions": {
45+
"strings": true
46+
}
47+
}

0 commit comments

Comments
 (0)