Skip to content

Commit 333fd31

Browse files
authored
Merge pull request #498 from gitKrystan/typescript
Convert to TypeScript
2 parents 96fa9bf + e694355 commit 333fd31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5059
-3972
lines changed

.eslintrc.js

Lines changed: 131 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,145 @@
1+
'use strict';
2+
13
module.exports = {
24
root: true,
5+
parser: '@babel/eslint-parser',
36
parserOptions: {
4-
ecmaVersion: 2017
7+
sourceType: 'module',
8+
requireConfigFile: false,
59
},
610
env: {
11+
browser: false,
712
node: true,
8-
es6: true
13+
es6: true,
914
},
10-
extends: ["eslint:recommended", "prettier"],
11-
plugins: ["prettier"],
15+
extends: [
16+
'eslint:recommended',
17+
'plugin:eslint-comments/recommended',
18+
'plugin:jsdoc/recommended',
19+
'plugin:unicorn/recommended',
20+
'prettier',
21+
],
22+
plugins: ['jsdoc', 'unicorn'],
23+
reportUnusedDisableDirectives: true,
1224
rules: {
13-
"prettier/prettier": "error"
25+
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
26+
'eslint-comments/no-unused-disable': 'error',
27+
'jsdoc/check-param-names': 'off',
28+
'jsdoc/newline-after-description': 'off',
29+
'jsdoc/require-jsdoc': ['error', { publicOnly: true }],
30+
'jsdoc/require-returns': 'off',
31+
'jsdoc/require-returns-type': 'off',
32+
'jsdoc/require-param': 'off',
33+
'jsdoc/require-param-type': 'off',
34+
'jsdoc/tag-lines': 'off',
35+
'no-console': 'error',
36+
'unicorn/catch-error-name': 'off',
37+
'unicorn/consistent-destructuring': 'off',
38+
'unicorn/consistent-function-scoping': ['error', { checkArrowFunctions: false }],
39+
'unicorn/custom-error-definition': 'error',
40+
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
41+
'unicorn/no-array-callback-reference': 'off',
42+
'unicorn/no-array-method-this-argument': 'off', // False positives
43+
'unicorn/no-null': 'off',
44+
'unicorn/prefer-node-protocol': 'off',
45+
'unicorn/prefer-ternary': ['error', 'only-single-line'],
46+
'unicorn/prevent-abbreviations': 'off',
1447
},
1548
overrides: [
49+
// node files
50+
{
51+
files: [
52+
'./.eslintrc.js',
53+
'./.prettierrc.js',
54+
'./bin/**/*.js',
55+
'./test/run-test.js',
56+
'./transforms/ember-object/test.js',
57+
],
58+
parserOptions: {
59+
sourceType: 'script',
60+
},
61+
env: {
62+
browser: false,
63+
node: true,
64+
},
65+
plugins: ['node'],
66+
extends: ['plugin:node/recommended'],
67+
rules: {
68+
'no-process-exit': 'off',
69+
// this can be removed once the following is fixed
70+
// https://github.com/mysticatea/eslint-plugin-node/issues/77
71+
'node/no-unpublished-require': 'off',
72+
'node/shebang': 'off',
73+
'unicorn/no-process-exit': 'off',
74+
'unicorn/prefer-module': 'off',
75+
'unicorn/prefer-top-level-await': 'off',
76+
},
77+
},
78+
// test files
1679
{
1780
files: ['**/*.test.js'],
1881
env: {
19-
jest: true
20-
}
21-
}
22-
]
82+
jest: true,
83+
},
84+
},
85+
// typescript files
86+
{
87+
files: ['*.ts'],
88+
parser: '@typescript-eslint/parser',
89+
parserOptions: {
90+
project: './tsconfig.json',
91+
allowAutomaticSingleRunInference: true,
92+
},
93+
plugins: ['@typescript-eslint'],
94+
extends: [
95+
'plugin:@typescript-eslint/recommended',
96+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
97+
'plugin:@typescript-eslint/strict',
98+
],
99+
rules: {
100+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
101+
'@typescript-eslint/ban-ts-comment': [
102+
'error',
103+
{
104+
'ts-expect-error': 'allow-with-description',
105+
'ts-ignore': true,
106+
'ts-nocheck': true,
107+
},
108+
],
109+
'@typescript-eslint/consistent-type-assertions': 'error',
110+
'@typescript-eslint/consistent-type-definitions': 'error',
111+
'@typescript-eslint/consistent-type-imports': 'error',
112+
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
113+
'@typescript-eslint/explicit-member-accessibility': [
114+
'error',
115+
{ accessibility: 'no-public' },
116+
],
117+
'@typescript-eslint/method-signature-style': 'error',
118+
'@typescript-eslint/consistent-indexed-object-style': 'error',
119+
'@typescript-eslint/no-base-to-string': 'error',
120+
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
121+
'@typescript-eslint/no-dynamic-delete': 'error',
122+
'@typescript-eslint/no-extra-semi': 'error',
123+
'@typescript-eslint/no-extraneous-class': 'error',
124+
'@typescript-eslint/no-explicit-any': 'error',
125+
'@typescript-eslint/no-implicit-any-catch': 'error',
126+
'@typescript-eslint/no-invalid-void-type': 'error',
127+
'@typescript-eslint/no-require-imports': 'error',
128+
'@typescript-eslint/no-unnecessary-condition': 'error',
129+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
130+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
131+
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
132+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
133+
'@typescript-eslint/prefer-enum-initializers': 'error',
134+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
135+
'@typescript-eslint/prefer-for-of': 'error',
136+
'@typescript-eslint/prefer-includes': 'error',
137+
'@typescript-eslint/prefer-literal-enum-member': 'error',
138+
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
139+
'@typescript-eslint/require-array-sort-compare': 'error',
140+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
141+
'@typescript-eslint/unified-signatures': 'error',
142+
},
143+
},
144+
],
23145
};

.github/workflows/ci.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,24 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
strategy:
1514
matrix:
1615
node-version: [14.x, 16.x, 18.x]
1716

1817
steps:
19-
- uses: actions/checkout@v2
20-
- uses: actions/setup-node@v3
21-
with:
22-
node-version: ${{ matrix.node-version }}
23-
cache: yarn
24-
- run: yarn install --frozen-lockfile
25-
- run: yarn lint:js
26-
- run: yarn test
18+
- uses: actions/checkout@v2
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: yarn
23+
- run: yarn install --frozen-lockfile
24+
- run: yarn lint:js
25+
- run: yarn test

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
*.log
2+
*.log
3+
.eslintcache

.prettierignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
*.log
3+
.eslintcache
4+
**/__testfixtures__/**
5+
**/fixtures/**
6+
CHANGELOG.md

.prettierrc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
module.exports = {
44
singleQuote: true,
5-
trailingComma: 'es5',
65
printWidth: 100,
6+
overrides: [
7+
{
8+
files: '*.ts',
9+
options: {
10+
printWidth: 80,
11+
},
12+
},
13+
],
714
};

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"typescript.preferences.importModuleSpecifierEnding": "index",
5+
"typescript.suggest.autoImports": true
6+
}

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ addons that the codemod will add imports from:
1313

1414
```
1515
ember install ember-classic-decorator
16-
ember install ember-decorators
16+
ember install ember-decorators
1717
```
1818

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

2626
The codemod accepts the following options:
2727

28-
| Option | Value | Default | Details |
28+
| Option | Value | Default | Details |
2929
| --------------------- | ------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
3030
| `--class-fields` | boolean | `true` | Enable/disable transformation using class fields |
3131
| `--decorators` | boolean | `true` | Enable/disable transformation using decorators |
@@ -87,8 +87,9 @@ transformation of
8787
## More Transform Examples
8888

8989
<!--TRANSFORMS_START-->
90-
* [ember-object](transforms/ember-object/README.md)
91-
* [helpers](transforms/helpers/README.md)
90+
91+
- [ember-object](transforms/ember-object/README.md)
92+
- [helpers](transforms/helpers/README.md)
9293
<!--TRANSFORMS_END-->
9394

9495
## Contributing

RELEASE.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ guiding principle here is that changelogs are for humans, not machines.
1717

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

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

2727
## Release
2828

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

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

3333
```sh
3434
yarn install
3535
```
3636

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

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

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

5252
```sh
5353
npx release-it

package.json

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,23 @@
3131
],
3232
"scripts": {
3333
"release": "release-it",
34-
"lint:js": "eslint .",
35-
"test": "codemod-cli test && node ./test/run-test.js",
34+
"prepare": "yarn build",
35+
"postpublish": "yarn clean",
36+
"build": "tsc",
37+
"clean": "tsc --build --clean",
38+
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
39+
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
40+
"lint:js": "eslint . --cache",
41+
"lint:js:fix": "eslint . --fix",
42+
"lint:prettier": "prettier --check .",
43+
"lint:prettier:fix": "prettier --write .",
44+
"lint:ts": "tsc --noEmit",
45+
"test": "yarn build && codemod-cli test && node ./test/run-test.js && yarn clean",
3646
"update-docs": "codemod-cli update-docs"
3747
},
3848
"dependencies": {
39-
"codemod-cli": "^2.0.0",
49+
"camelcase": "^6.3.0",
50+
"codemod-cli": "^3.2.0",
4051
"ember-codemods-telemetry-helpers": "^3.0.0",
4152
"fs-extra": "^8.0.1",
4253
"git-repo-info": "^2.1.0",
@@ -47,17 +58,29 @@
4758
"winston": "^3.2.1"
4859
},
4960
"devDependencies": {
50-
"eslint": "^6.0.0",
51-
"eslint-config-prettier": "^6.0.0",
52-
"eslint-plugin-prettier": "^3.1.0",
61+
"@babel/core": "^7.20.12",
62+
"@babel/eslint-parser": "^7.19.1",
63+
"@babel/preset-env": "^7.20.2",
64+
"@tsconfig/node12": "^1.0.11",
65+
"@types/jscodeshift": "^0.11.6",
66+
"@typescript-eslint/eslint-plugin": "^5.48.1",
67+
"@typescript-eslint/parser": "^5.48.1",
68+
"concurrently": "^7.6.0",
69+
"eslint": "^8.31.0",
70+
"eslint-config-prettier": "^8.6.0",
71+
"eslint-plugin-eslint-comments": "^3.2.0",
72+
"eslint-plugin-jsdoc": "^39.6.4",
73+
"eslint-plugin-node": "^11.1.0",
74+
"eslint-plugin-unicorn": "^45.0.2",
5375
"execa": "^5.0.0",
5476
"jest": "^27.0.1",
55-
"prettier": "^2.0.4",
77+
"prettier": "^2.8.2",
5678
"release-it": "^14.2.1",
57-
"release-it-lerna-changelog": "^3.1.0"
79+
"release-it-lerna-changelog": "^3.1.0",
80+
"typescript": "^4.9.4"
5881
},
5982
"engines": {
60-
"node": "10.* || 12.* || >= 14"
83+
"node": "12.* || >= 14"
6184
},
6285
"publishConfig": {
6386
"registry": "https://registry.npmjs.org"

0 commit comments

Comments
 (0)