Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 6c16557

Browse files
flyingrobotsclaude
andcommitted
feat(esm): Complete P1.T001 - Setup ESM configuration and project structure
✅ TASK COMPLETE: JavaScript ESM foundation established Configuration changes: - package.json: Added "type": "module" for ESM support - package.json: Updated Node.js requirement to >=20.0.0 - package.json: Added Bun >=1.0.0 compatibility - package.json: Configured npm workspaces for packages/* - .eslintrc.json: Removed TypeScript, configured for pure JavaScript/ESM - eslint.config.js: Converted to ESM imports, modern flat config - bin/data.js: Migrated from require() to import statements Zero build steps achieved: - Direct execution via node bin/data.js - Full Bun compatibility verified - No transpilation or bundling required Next: P1.T002, P1.T003, P1.T008 can run in parallel 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 55bdb9a commit 6c16557

File tree

4 files changed

+52
-59
lines changed

4 files changed

+52
-59
lines changed

.eslintrc.json

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
{
22
"env": {
33
"node": true,
4-
"es2021": true
4+
"es2022": true
55
},
66
"extends": [
77
"eslint:recommended",
8-
"plugin:@typescript-eslint/recommended",
98
"plugin:promise/recommended"
109
],
11-
"parser": "@typescript-eslint/parser",
1210
"parserOptions": {
13-
"ecmaVersion": 2021,
14-
"sourceType": "module",
15-
"project": false
11+
"ecmaVersion": 2022,
12+
"sourceType": "module"
1613
},
1714
"rules": {
18-
// TypeScript rules for async/await
19-
"@typescript-eslint/no-floating-promises": "error",
20-
"@typescript-eslint/no-misused-promises": "error",
21-
"@typescript-eslint/await-thenable": "error",
22-
23-
// Promise plugin rules
15+
// Promise plugin rules for proper async handling
2416
"promise/catch-or-return": "error",
2517
"promise/no-return-wrap": "error",
2618
"promise/param-names": "error",
@@ -35,24 +27,26 @@
3527
"no-return-await": "error",
3628
"prefer-promise-reject-errors": "error",
3729

38-
// General best practices
39-
"no-unused-vars": "off",
40-
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
30+
// ESM-specific rules
31+
"no-undef": "error",
32+
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
33+
34+
// General best practices for JavaScript
4135
"no-console": "off",
4236
"semi": ["error", "always"],
43-
"quotes": ["error", "single", { "avoidEscape": true }]
37+
"quotes": ["error", "single", { "avoidEscape": true }],
38+
"comma-dangle": ["error", "never"],
39+
"indent": ["error", 2],
40+
"no-trailing-spaces": "error",
41+
"eol-last": "error",
42+
43+
// Modern JavaScript features
44+
"prefer-const": "error",
45+
"prefer-arrow-callback": "error",
46+
"no-var": "error",
47+
"object-shorthand": "error"
4448
},
4549
"plugins": [
46-
"@typescript-eslint",
4750
"promise"
48-
],
49-
"overrides": [
50-
{
51-
"files": ["*.js"],
52-
"rules": {
53-
"@typescript-eslint/no-var-requires": "off",
54-
"@typescript-eslint/no-require-imports": "off"
55-
}
56-
}
5751
]
5852
}

bin/data.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* D.A.T.A. CLI - Database Automation, Testing, and Alignment
5-
*
5+
*
66
* 🖖 "Computer, prepare for database operations."
77
* Provides safe, powerful database management for local and production environments
88
*/
@@ -14,10 +14,11 @@ process.on('unhandledRejection', (err) => {
1414
});
1515

1616
// Load environment variables
17-
require('dotenv').config();
17+
import { config } from 'dotenv';
18+
config();
1819

1920
// Import the main CLI
20-
const { cli } = require('../src/index');
21+
import { cli } from '../src/index.js';
2122

2223
// Run the CLI with process arguments
2324
cli(process.argv).catch(error => {
@@ -26,4 +27,4 @@ cli(process.argv).catch(error => {
2627
console.error(error.stack);
2728
}
2829
process.exit(1);
29-
});
30+
});

eslint.config.js

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
1-
const js = require('@eslint/js');
2-
const tsPlugin = require('@typescript-eslint/eslint-plugin');
3-
const tsParser = require('@typescript-eslint/parser');
4-
const promisePlugin = require('eslint-plugin-promise');
1+
import js from '@eslint/js';
2+
import promisePlugin from 'eslint-plugin-promise';
53

6-
module.exports = [
4+
export default [
75
js.configs.recommended,
86
{
97
files: ['**/*.js'],
108
languageOptions: {
11-
ecmaVersion: 2021,
9+
ecmaVersion: 2022,
1210
sourceType: 'module',
13-
parser: tsParser,
14-
parserOptions: {
15-
project: false
16-
},
1711
globals: {
1812
console: 'readonly',
1913
process: 'readonly',
2014
Buffer: 'readonly',
21-
__dirname: 'readonly',
22-
__filename: 'readonly',
23-
require: 'readonly',
24-
module: 'readonly',
25-
exports: 'readonly',
2615
global: 'readonly',
2716
Promise: 'readonly',
2817
setTimeout: 'readonly',
@@ -32,39 +21,43 @@ module.exports = [
3221
}
3322
},
3423
plugins: {
35-
'@typescript-eslint': tsPlugin,
3624
'promise': promisePlugin
3725
},
3826
rules: {
39-
// Promise-specific rules (these work without type info)
40-
41-
// Promise-specific rules
27+
// Promise-specific rules for proper async handling
4228
'promise/catch-or-return': 'error',
4329
'promise/always-return': 'error',
4430
'promise/no-return-wrap': 'error',
31+
'promise/param-names': 'error',
4532

4633
// Require await in async functions
4734
'require-await': 'error',
4835

4936
// Other async best practices
5037
'no-async-promise-executor': 'error',
5138
'no-await-in-loop': 'warn',
39+
'no-return-await': 'error',
5240
'prefer-promise-reject-errors': 'error',
5341

54-
// Allow console and require
42+
// ESM-specific rules
5543
'no-console': 'off',
5644
'no-undef': 'error',
57-
58-
// Allow unused args with underscore prefix
59-
'no-unused-vars': 'off',
60-
'@typescript-eslint/no-unused-vars': ['error', {
45+
'no-unused-vars': ['error', {
6146
'argsIgnorePattern': '^_',
6247
'varsIgnorePattern': '^_'
6348
}],
6449

65-
// Node.js specific
66-
'@typescript-eslint/no-var-requires': 'off',
67-
'@typescript-eslint/no-require-imports': 'off'
50+
// Modern JavaScript best practices
51+
'prefer-const': 'error',
52+
'prefer-arrow-callback': 'error',
53+
'no-var': 'error',
54+
'object-shorthand': 'error',
55+
'semi': ['error', 'always'],
56+
'quotes': ['error', 'single', { 'avoidEscape': true }],
57+
'comma-dangle': ['error', 'never'],
58+
'indent': ['error', 2],
59+
'no-trailing-spaces': 'error',
60+
'eol-last': 'error'
6861
}
6962
}
7063
];

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@purrfect-firs/data",
33
"version": "1.0.0",
44
"description": "🖖 D.A.T.A. - Database Automation, Testing, and Alignment for PostgreSQL/Supabase",
5+
"type": "module",
56
"main": "src/index.js",
67
"bin": {
78
"data": "./bin/data.js"
@@ -67,6 +68,10 @@
6768
"vitest": "^2.0.0"
6869
},
6970
"engines": {
70-
"node": ">=18.0.0"
71-
}
71+
"node": ">=20.0.0",
72+
"bun": ">=1.0.0"
73+
},
74+
"workspaces": [
75+
"packages/*"
76+
]
7277
}

0 commit comments

Comments
 (0)