Skip to content

Commit

Permalink
Introduce TypeScript (#31)
Browse files Browse the repository at this point in the history
* chore: Updated eslint and prettier configurations

* chore: Installed typescript

* chore: Patched @codemod-utils/files

* chore: Updated file extension

* chore: Added types

---------

Co-authored-by: ijlee2 <ijlee2@users.noreply.github.com>
  • Loading branch information
ijlee2 and ijlee2 authored Jun 12, 2023
1 parent e31b4db commit ec1a5cc
Show file tree
Hide file tree
Showing 188 changed files with 1,237 additions and 193 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# compiled output
/dist/
/dist-for-testing/
/tmp/

# dependencies
Expand Down
45 changes: 38 additions & 7 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,58 @@

module.exports = {
root: true,
parser: '@babel/eslint-parser',
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
requireConfigFile: false,
sourceType: 'module',
},
plugins: ['simple-import-sort'],
plugins: ['@typescript-eslint', 'simple-import-sort', 'typescript-sort-keys'],
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:n/recommended',
'plugin:prettier/recommended',
'plugin:typescript-sort-keys/recommended',
],
rules: {
curly: 'error',
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
},
env: {
es6: true,
node: true,
settings: {
'import/resolver': {
node: true,
typescript: true,
},
},
overrides: [],
overrides: [
// TypeScript files
{
files: ['**/*.{cts,ts}'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'@typescript-eslint/array-type': 'error',
},
},
// TypeScript and JavaScript files
{
files: ['**/*.{cjs,cts,js,ts}'],
rules: {
'import/no-duplicates': 'error',
},
},
// Node files
{
files: ['./.eslintrc.{cjs,js}', './.prettierrc.{cjs,js}'],
env: {
browser: false,
node: true,
},
extends: ['plugin:n/recommended'],
},
],
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# compiled output
dist/
dist-for-testing/
tmp/

# dependencies
Expand Down
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# compiled output
/dist/
/tmp/

# dependencies
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module.exports = {
overrides: [
{
files: '*.{cjs,js}',
files: '*.{cjs,cts,js,mjs,mts,ts}',
options: {
printWidth: 80,
singleQuote: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env node
'use strict';

import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

import { runCodemod } from '../src/index.js';
import type { CodemodOptions } from '../src/types/index.js';

// Provide a title to the process in `ps`
process.title = 'ember-codemod-pod-to-octane';

// Set codemod options
const { argv } = yargs(hideBin(process.argv))
const argv = yargs(hideBin(process.argv))
.option('pod-path', {
default: '',
describe: 'Namespace used for the pod layout',
Expand All @@ -26,13 +26,14 @@ const { argv } = yargs(hideBin(process.argv))
type: 'boolean',
})
.option('type', {
choices: ['addon', 'app', 'engine'],
choices: ['addon', 'app', 'engine'] as const,
demandOption: true,
describe: 'Type of your Ember project',
type: 'string',
});
})
.parseSync();

const codemodOptions = {
const codemodOptions: CodemodOptions = {
podPath: argv['pod-path'],
projectRoot: argv['root'] ?? process.cwd(),
projectType: argv['type'],
Expand Down
44 changes: 36 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,35 @@
"license": "MIT",
"author": "Isaac J. Lee",
"type": "module",
"main": "src/index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
"dist/*"
]
}
},
"bin": "./bin/ember-codemod-pod-to-octane.js",
"directories": {
"test": "tests"
},
"files": [
"bin/",
"src/"
"dist"
],
"scripts": {
"build": "tsc --project tsconfig.build.json",
"changelog": "lerna-changelog",
"lint": "eslint . --cache",
"lint:fix": "eslint . --fix",
"test": "mt tests --quiet"
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "tsc --noEmit",
"prepare": "pnpm build",
"test": "tsc --build && mt dist-for-testing --quiet"
},
"dependencies": {
"@codemod-utils/files": "^0.4.0",
"@codemod-utils/files": "^0.4.1",
"@codemod-utils/json": "^0.3.0",
"yargs": "^17.7.2"
},
Expand All @@ -40,14 +52,25 @@
"@babel/eslint-parser": "^7.22.5",
"@codemod-utils/tests": "^0.2.1",
"@sondr3/minitest": "^0.1.1",
"@tsconfig/esm": "^1.0.3",
"@tsconfig/node16": "^1.0.4",
"@tsconfig/strictest": "^2.0.1",
"@types/node": "^16.11.7",
"@types/yargs": "^17.0.24",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"concurrently": "^8.2.0",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-typescript-sort-keys": "^2.3.0",
"lerna-changelog": "^2.2.0",
"prettier": "^2.8.8"
"prettier": "^2.8.8",
"typescript": "^5.1.3"
},
"engines": {
"node": ">= 16"
Expand All @@ -61,5 +84,10 @@
"enhance: documentation": "Documentation",
"user feedback": "User Feedback"
}
},
"pnpm": {
"overrides": {
"eslint-plugin-import@2.27.5>tsconfig-paths": "^4.2.0"
}
}
}
Loading

0 comments on commit ec1a5cc

Please sign in to comment.