Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce TypeScript #31

Merged
merged 5 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, I'm unsure whether an end-developer will be able to continue to use npx to run the codemod. Will check this after publishing a new version.

],
"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"
}
Comment on lines +88 to +91
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}
Loading