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

Convert to TypeScript #498

Merged
merged 54 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5423a0f
Initial TS setup
gitKrystan Jan 12, 2023
5495931
Resolve type-checking errors in index.ts
gitKrystan Jan 12, 2023
bac24b8
Rename parse-helper to TS
gitKrystan Jan 12, 2023
3e34394
Fix parse-helper type-checking errors
gitKrystan Jan 12, 2023
bcbe1cb
Rename EOProp to TS
gitKrystan Jan 12, 2023
218ae1a
Fix EOProp type-checking errors
gitKrystan Jan 12, 2023
02a134e
Rename util/index to TS
gitKrystan Jan 12, 2023
e73686e
Fix helper/util type-checking errors
gitKrystan Jan 12, 2023
ee66721
Rename validation-helper to TS
gitKrystan Jan 12, 2023
13d5554
Fix validation-helper TS errors
gitKrystan Jan 12, 2023
9938fb0
Rename log-helper to TS
gitKrystan Jan 12, 2023
2e7b389
Fix log-helper TS errors
gitKrystan Jan 12, 2023
c7aef05
Switch to @tsconfig/node-lts-strictest and upgrade codemod-cli (jscod…
gitKrystan Jan 12, 2023
30ea896
Rename import-helper to TS
gitKrystan Jan 12, 2023
62e3778
Fix import-helper TS errors
gitKrystan Jan 12, 2023
1b78735
Rename transform-helper to TS
gitKrystan Jan 12, 2023
247f9a4
Fix transform-helper TS errors
gitKrystan Jan 13, 2023
f6dee6b
Rename decorator-helper to TS
gitKrystan Jan 13, 2023
f20d24d
Fix decorator-helper TS errors
gitKrystan Jan 13, 2023
eddc688
Clean up EOProp _prop type
gitKrystan Jan 13, 2023
92a6c52
Upgrade linters + TS support
gitKrystan Jan 13, 2023
4db945a
Remove forEach where possible
gitKrystan Jan 13, 2023
3b11914
Prefer spread operator
gitKrystan Jan 13, 2023
c173191
Remove usages of reduce
gitKrystan Jan 14, 2023
5b14580
Enable more @typescript-eslint recommended rules
gitKrystan Jan 17, 2023
3587135
Clean up EOProps class
gitKrystan Jan 17, 2023
5935fc1
Extract EOCallExpressionProp from EOProp
gitKrystan Jan 17, 2023
8693b3b
Extract EOFunctionExpressionProp
gitKrystan Jan 18, 2023
a38ef6a
Extract EOClassDecoratorProp
gitKrystan Jan 18, 2023
404ad82
Extract EOActionsObjectProp
gitKrystan Jan 18, 2023
2108026
Extract some EOClassDecoratorProp specific logic
gitKrystan Jan 18, 2023
a822cb0
Extract EOBaseProp
gitKrystan Jan 18, 2023
eab9df1
Clean up EOProp references
gitKrystan Jan 18, 2023
41cb659
More EOProp cleanup
gitKrystan Jan 18, 2023
3efb5aa
Clean up EOActionsObjectProp
gitKrystan Jan 18, 2023
bf21604
Clean up EOCallExpressionProp
gitKrystan Jan 18, 2023
74e4343
More clean up
gitKrystan Jan 19, 2023
6e53e44
Clean up FunctionProp
gitKrystan Jan 19, 2023
d7e5335
Re-enable ban-ts-comment lint
gitKrystan Jan 19, 2023
7002551
Clean up constants
gitKrystan Jan 19, 2023
ef6b938
Clean up FIXMEs
gitKrystan Jan 19, 2023
750dc5d
Clean up imports
gitKrystan Jan 19, 2023
54d9935
Clean up tsconfig
gitKrystan Jan 19, 2023
d1f595f
Clean up replaceEmberObjectExpressions
gitKrystan Jan 19, 2023
f9b4b79
Clean up index.ts and parse-helper.ts
gitKrystan Jan 19, 2023
d100e7c
Clean up AST types
gitKrystan Jan 20, 2023
24f84b5
Fixes discovered during dogfooding
gitKrystan Jan 20, 2023
e19ac57
REVERT: Dogfooding updates
gitKrystan Jan 23, 2023
f0da8d9
Clean up EOCallExpressionProp
gitKrystan Jan 23, 2023
5999ac9
Allow Object.freeze calls
gitKrystan Jan 23, 2023
64d7cd3
Allow logical expressions
gitKrystan Jan 23, 2023
067b0e8
More cleanup from dogfooding
gitKrystan Jan 23, 2023
e1a6b47
Clean up validation errors
gitKrystan Jan 23, 2023
e694355
Revert dev hacks
gitKrystan Jan 24, 2023
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
140 changes: 131 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,145 @@
'use strict';

module.exports = {
root: true,
parser: '@babel/eslint-parser',
parserOptions: {
ecmaVersion: 2017
sourceType: 'module',
requireConfigFile: false,
},
env: {
browser: false,
node: true,
es6: true
es6: true,
},
extends: ["eslint:recommended", "prettier"],
plugins: ["prettier"],
extends: [
'eslint:recommended',
'plugin:eslint-comments/recommended',
'plugin:jsdoc/recommended',
'plugin:unicorn/recommended',
'prettier',
],
plugins: ['jsdoc', 'unicorn'],
reportUnusedDisableDirectives: true,
rules: {
"prettier/prettier": "error"
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
'eslint-comments/no-unused-disable': 'error',
'jsdoc/check-param-names': 'off',
'jsdoc/newline-after-description': 'off',
'jsdoc/require-jsdoc': ['error', { publicOnly: true }],
'jsdoc/require-returns': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/require-param': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/tag-lines': 'off',
'no-console': 'error',
'unicorn/catch-error-name': 'off',
'unicorn/consistent-destructuring': 'off',
'unicorn/consistent-function-scoping': ['error', { checkArrowFunctions: false }],
'unicorn/custom-error-definition': 'error',
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-array-method-this-argument': 'off', // False positives
'unicorn/no-null': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/prefer-ternary': ['error', 'only-single-line'],
'unicorn/prevent-abbreviations': 'off',
},
overrides: [
// node files
{
files: [
'./.eslintrc.js',
'./.prettierrc.js',
'./bin/**/*.js',
'./test/run-test.js',
'./transforms/ember-object/test.js',
],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
plugins: ['node'],
extends: ['plugin:node/recommended'],
rules: {
'no-process-exit': 'off',
// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'node/no-unpublished-require': 'off',
'node/shebang': 'off',
'unicorn/no-process-exit': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-top-level-await': 'off',
},
},
// test files
{
files: ['**/*.test.js'],
env: {
jest: true
}
}
]
jest: true,
},
},
// typescript files
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
allowAutomaticSingleRunInference: true,
},
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
],
rules: {
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': true,
'ts-nocheck': true,
},
],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{ accessibility: 'no-public' },
],
'@typescript-eslint/method-signature-style': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-extra-semi': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-implicit-any-catch': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-literal-enum-member': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/unified-signatures': 'error',
},
},
],
};
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@ name: CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn lint:js
- run: yarn test
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn lint:js
- run: yarn test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
*.log
*.log
.eslintcache
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
*.log
.eslintcache
**/__testfixtures__/**
**/fixtures/**
CHANGELOG.md
9 changes: 8 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

module.exports = {
singleQuote: true,
trailingComma: 'es5',
printWidth: 100,
overrides: [
{
files: '*.ts',
options: {
printWidth: 80,
},
},
],
};
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.preferences.importModuleSpecifierEnding": "index",
"typescript.suggest.autoImports": true
}
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ addons that the codemod will add imports from:

```
ember install ember-classic-decorator
ember install ember-decorators
ember install ember-decorators
```

Then, boot up your application. Then, the codemod can be run using the
Expand All @@ -25,7 +25,7 @@ npx ember-native-class-codemod http://localhost:4200/path/to/server [OPTIONS] pa

The codemod accepts the following options:

| Option | Value | Default | Details |
| Option | Value | Default | Details |
| --------------------- | ------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--class-fields` | boolean | `true` | Enable/disable transformation using class fields |
| `--decorators` | boolean | `true` | Enable/disable transformation using decorators |
Expand Down Expand Up @@ -87,8 +87,9 @@ transformation of
## More Transform Examples

<!--TRANSFORMS_START-->
* [ember-object](transforms/ember-object/README.md)
* [helpers](transforms/helpers/README.md)

- [ember-object](transforms/ember-object/README.md)
- [helpers](transforms/helpers/README.md)
<!--TRANSFORMS_END-->

## Contributing
Expand Down
16 changes: 8 additions & 8 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ guiding principle here is that changelogs are for humans, not machines.

When reviewing merged PR's the labels to be used are:

* breaking - Used when the PR is considered a breaking change.
* enhancement - Used when the PR adds a new feature or enhancement.
* bug - Used when the PR fixes a bug included in a previous release.
* documentation - Used when the PR adds or updates documentation.
* internal - Used for internal changes that still require a mention in the
- breaking - Used when the PR is considered a breaking change.
- enhancement - Used when the PR adds a new feature or enhancement.
- bug - Used when the PR fixes a bug included in a previous release.
- documentation - Used when the PR adds or updates documentation.
- internal - Used for internal changes that still require a mention in the
changelog/release notes.

## Release

Once the prep work is completed, the actual release is straight forward:

* First, ensure that you have installed your projects dependencies:
- First, ensure that you have installed your projects dependencies:

```sh
yarn install
```

* Second, ensure that you have obtained a
- Second, ensure that you have obtained a
[GitHub personal access token][generate-token] with the `repo` scope (no
other permissions are needed). Make sure the token is available as the
`GITHUB_AUTH` environment variable.
Expand All @@ -47,7 +47,7 @@ yarn install

[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable

* And last (but not least 😁) do your release.
- And last (but not least 😁) do your release.

```sh
npx release-it
Expand Down
41 changes: 32 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,23 @@
],
"scripts": {
"release": "release-it",
"lint:js": "eslint .",
"test": "codemod-cli test && node ./test/run-test.js",
"prepare": "yarn build",
"postpublish": "yarn clean",
"build": "tsc",
"clean": "tsc --build --clean",
"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:prettier": "prettier --check .",
"lint:prettier:fix": "prettier --write .",
"lint:ts": "tsc --noEmit",
"test": "yarn build && codemod-cli test && node ./test/run-test.js && yarn clean",
"update-docs": "codemod-cli update-docs"
},
"dependencies": {
"codemod-cli": "^2.0.0",
"camelcase": "^6.3.0",
"codemod-cli": "^3.2.0",
"ember-codemods-telemetry-helpers": "^3.0.0",
"fs-extra": "^8.0.1",
"git-repo-info": "^2.1.0",
Expand All @@ -47,17 +58,29 @@
"winston": "^3.2.1"
},
"devDependencies": {
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"@babel/core": "^7.20.12",
"@babel/eslint-parser": "^7.19.1",
"@babel/preset-env": "^7.20.2",
"@tsconfig/node12": "^1.0.11",
"@types/jscodeshift": "^0.11.6",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
"concurrently": "^7.6.0",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-jsdoc": "^39.6.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unicorn": "^45.0.2",
"execa": "^5.0.0",
"jest": "^27.0.1",
"prettier": "^2.0.4",
"prettier": "^2.8.2",
"release-it": "^14.2.1",
"release-it-lerna-changelog": "^3.1.0"
"release-it-lerna-changelog": "^3.1.0",
"typescript": "^4.9.4"
},
"engines": {
"node": "10.* || 12.* || >= 14"
"node": "12.* || >= 14"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
Expand Down
Loading