Skip to content

Commit 57b1970

Browse files
committed
chore: better terminal scripts
1 parent 55f439a commit 57b1970

5 files changed

Lines changed: 80 additions & 7 deletions

File tree

.eslintignore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
node_modules/**
1+
node_modules/**
2+
vendor/**
3+
build/**
4+
dist/**
5+
*.min.js
6+
*.bundle.js
7+
*.snap
8+
*.log
9+
*.lock
10+
*.map
11+
*.test.js
12+
*.test.jsx
13+
*.test.ts
14+
*.test.tsx
15+
*.spec.js
16+
*.spec.jsx
17+
*.spec.ts
18+
*.spec.tsx
19+
example/vendor/**
20+
example/build/**
21+
example/dist/**

.prettierignore

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
node_modules/**
1+
node_modules/**
2+
vendor/**
3+
build/**
4+
example/vendor/**
5+
example/build/**
6+
example/dist/**
7+
*.min.js
8+
*.bundle.js
9+
*.snap
10+
*.log
11+
*.lock
12+
*.map
13+
*.d.ts
14+
*.test.js
15+
*.test.jsx
16+
*.test.ts
17+
*.test.tsx
18+
*.spec.js
19+
*.spec.jsx
20+
*.spec.ts
21+
*.spec.tsx

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-typescript-library-starter",
3-
"version": "1.5.0",
3+
"version": "1.6.0",
44
"description": "Extremely easy to create a React Native Component Library with both Stateful and Functional Component Examples.",
55
"main": "./build/dist/index.js",
66
"repository": "git@github.com:WrathChaos/react-native-typescript-library-starter.git",
@@ -26,10 +26,8 @@
2626
"scripts": {
2727
"build": "tsc -p tsconfig.json && npm run copy:assets && npm run copy:package",
2828
"prepare": "husky install",
29-
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx}\"",
30-
"lint": "eslint \"lib/**/*.{ts,tsx,js,jsx}\"",
31-
"prettier": "npx prettier --write . && git add .",
32-
"husky:setup": "npx husky-init && npm run husky:commitlint && npm run husky:prettier && npm run husky:lint",
29+
"lint": "node scripts/terminal/lint.mjs",
30+
"prettier": "node scripts/terminal/prettier.mjs", "husky:setup": "npx husky-init && npm run husky:commitlint && npm run husky:prettier && npm run husky:lint",
3331
"husky:commitlint": "npx husky add .husky/commit-msg 'npx --no-install commitlint --edit'",
3432
"semantic-release": "semantic-release",
3533
"copy:assets": "cpx 'lib/local-assets/**' 'build/dist/local-assets'",

scripts/terminal/lint.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { exec } from 'child_process';
2+
import chalk from 'chalk';
3+
import ora from 'ora';
4+
5+
const spinner = ora(chalk.magenta('Linting code...')).start();
6+
spinner.color = 'magenta';
7+
8+
// Adjust the ESLint command and glob pattern as needed for your project.
9+
exec('npx eslint "lib/**/*.{js,ts,tsx}" --fix', (error, stdout, stderr) => {
10+
// Clear the spinner line before outputting the final message.
11+
process.stdout.write('\r\x1b[K');
12+
13+
if (error) {
14+
spinner.fail(chalk.bgRed(`ESLint error: ${stderr || stdout}`));
15+
process.exit(1);
16+
} else {
17+
spinner.succeed(chalk.magentaBright('Code linted successfully!'));
18+
}
19+
});

scripts/terminal/prettier.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { exec } from 'child_process';
2+
import chalk from 'chalk';
3+
import ora from 'ora';
4+
5+
const spinner = ora(chalk.cyan('Formatting code...')).start();
6+
spinner.color = 'cyan';
7+
8+
// Adjust the Prettier command and glob pattern to match your project.
9+
exec('npx prettier --write "lib/**/*.{js,ts,tsx}"', (error, stdout, stderr) => {
10+
if (error) {
11+
spinner.fail(chalk.bgRed(`Prettier error: ${stderr}`));
12+
process.exit(1);
13+
} else {
14+
spinner.succeed(chalk.cyanBright('Code formatted successfully!'));
15+
}
16+
});

0 commit comments

Comments
 (0)