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

Utilize jscodeshift CLI results output #525

Merged
merged 15 commits into from
Apr 25, 2023
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = {
'unicorn/consistent-destructuring': 'off',
'unicorn/consistent-function-scoping': ['error', { checkArrowFunctions: false }],
'unicorn/custom-error-definition': 'error',
'unicorn/filename-case': ['error', { case: 'kebabCase' }],
'unicorn/filename-case': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-array-method-this-argument': 'off', // False positives
'unicorn/no-null': 'off',
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn lint:js
- run: yarn lint
- run: yarn test
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ The codemod accepts the following options, passed as CLI arguments, set in a `.c
| `--classic-decorator` / `classicDecorator` | `boolean` | `true` | Enable/disable adding the [`@classic` decorator](https://github.com/pzuraq/ember-classic-decorator), which helps with transitioning Ember Octane |
| `--type` / `type` | `'services' \| 'routes' \| 'components' \| 'controllers' \| undefined`' | `undefined` | Apply transformation to only passed type. If `undefined, will match all types in path. |
| `--quote` / `quote` | `'single' \| 'double'` | `'single'` | Whether to use double or single quotes by default for new statements that are added during the codemod. |
| `--partial-transforms` / `partialTransforms` | `boolean` | `true` | If `false`, the entire file will fail validation if any EmberObject within it fails validation. |
| `--ignore-leaking-state` / `ignoreLeakingState` | `string \| string[] | `['queryParams']` | Allow-list for `ObjectExpression` or `ArrayExpression` properties to ignore issues detailed in [eslint-plugin-ember/avoid-leaking-state-in-ember-objects](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/avoid-leaking-state-in-ember-objects.md). In the classic class syntax, using arrays and objects as default properties causes their state to "leak" between instances. If you have custom properties where you know that the shared state won't be a problem (for example, read-only configuration values), you can use this config to ignore them. NOTE: Passing this option will override the defaults, so ensure you include `'queryParams'` in the list unless you explicitly wish to disallow it. Pass as a comma-separated string if using as a CLI-option. Otherwise pass as an array of strings. |
| `DecoratorsConfig` | An object with the following properties. | See below. | A list of decorators that are allowed on object literal properties. (Method decorators will always be allowed.) When the codemod finds a field with one of these decorators, it will be translated directly into a class field with the same decorator. Including a decorator in this list means that you believe that the decorator will work correctly on a class field. Pass as a comma-separated string if using as a CLI-option. Otherwise pass as an array of strings. |
| `DecoratorsConfig.inObjectLiterals` | `string \| string[]` | `[]` | Allow-list for decorators currently applied to object literal properties that can be safely applied to class properties. Pass as a comma-separated string if using as a CLI-option. Otherwise pass as an array of strings. NOTE: Decorators on object methods will be allowed by default. |
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"deepmerge-ts": "^4.3.0",
"ember-codemods-telemetry-helpers": "^3.0.0",
"minimatch": "^7.4.6",
"walk-sync": "^3.0.0",
"winston": "^3.8.2",
"zod": "^3.21.4"
},
Expand All @@ -64,6 +63,7 @@
"@jest/globals": "^29.5.0",
"@release-it-plugins/lerna-changelog": "^5.0.0",
"@tsconfig/node12": "^1.0.11",
"@types/glob": "^8.1.0",
"@types/jscodeshift": "^0.11.6",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
Expand All @@ -75,6 +75,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-unicorn": "^46.0.0",
"execa": "^5.1.1",
"glob": "^8.1.0",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"release-it": "^15.10.1",
Expand Down
118 changes: 0 additions & 118 deletions test/helpers/expect-logs.ts

This file was deleted.

25 changes: 25 additions & 0 deletions test/helpers/expect-multiline.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Makes a regexp pattern to match multiline strings. String arguments passed to
* `makeMultilineMatcher` will be escaped then merged together into a regexp
* that will match partial lines of multi-line error messages when paired with
* Jest `expect().toThrow` or `expect.stringMatching`.
*
* @example
* ```
* const expected = makeMultilineMatcher('Line 1', 'Line 2', '3')
* //=> 'Line 1[\S\s]*Line 2[\S\s]*3'
*
* expect('Line 1\nLine 2\nLine 3').toEqual(expect.stringMatching(expected));
* //=> passes
* ```
*/
export function makeMultilineMatcher(...parts: string[]): string {
return parts.map(escapeRegExp).join('[\\S\\s]*');
}

/**
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
*/
function escapeRegExp(string: string): string {
return string.replace(/[$()*+.?[\\\]^{|}]/g, '\\$&'); // $& means the whole matched string
}
Loading