-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-plugin): renamed exported recommended
fix(eslint-plugin): turn yaml parser really optional deprecate(eslint-plugin): recommended exports based on types
- Loading branch information
Showing
8 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/angular/angular-cli/master/packages/angular_devkit/schematics/collection-schema.json", | ||
"schematics": { | ||
"migration-v11_4": { | ||
"version": "11.4.0-alpha.0", | ||
"description": "Updates of @o3r/eslint-plugin to v11.4.*", | ||
"factory": "./schematics/ng-update/v10-0/index#updateV11_4" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/@o3r/eslint-plugin/schematics/ng-update/v11/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* eslint-disable camelcase, @typescript-eslint/naming-convention */ | ||
import { chain, Rule, SchematicContext, Tree } from '@angular-devkit/schematics'; | ||
import { updateEslintJsonFile } from './update-configs/update-configs'; | ||
|
||
/** | ||
* Update of Otter library V10.0 | ||
*/ | ||
function updateV11_4Fn(): Rule { | ||
return (tree: Tree, context: SchematicContext) => { | ||
|
||
const updateRules: Rule[] = [ | ||
updateEslintJsonFile() | ||
]; | ||
|
||
return chain(updateRules)(tree, context); | ||
}; | ||
} | ||
|
||
/** | ||
* Update of Otter library V10.0 | ||
*/ | ||
export const updateV11_4 = () => { | ||
return import('@o3r/schematics') | ||
.catch(() => { updateV11_4Fn(); }) | ||
.then((schemtics) => schemtics?.createSchematicWithMetricsIfInstalled(updateV11_4Fn)); | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/@o3r/eslint-plugin/schematics/ng-update/v11/update-configs/update-configs.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Tree } from '@angular-devkit/schematics'; | ||
import { updateEslintJsonFile } from './update-configs'; | ||
|
||
describe('updateEslintJsonFile', () => { | ||
it('should update configs', () => { | ||
const initialTree = Tree.empty(); | ||
initialTree.create('random.file', 'a file containing json-recommended'); | ||
initialTree.create('/test/.eslintrc.json', '{ "extends": ["@o3r/json-recommended", "@other/json-recommended"] }'); | ||
initialTree.create('/src/.eslintrc.json', '{ "extends": ["plugin:@o3r/json-recommended", "@o3r/template-recommended"] }'); | ||
const newTree = updateEslintJsonFile()(initialTree, null as any) as Tree; | ||
|
||
expect(newTree.readText('random.file')).toContain('json-recommended'); | ||
expect(newTree.readText('/test/.eslintrc.json')).toBe('{ "extends": ["@o3r/monorepo-recommended", "@other/json-recommended"] }'); | ||
expect(newTree.readText('/src/.eslintrc.json')).toBe('{ "extends": ["plugin:@o3r/monorepo-recommended", "@o3r/angular-template-recommended"] }'); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
packages/@o3r/eslint-plugin/schematics/ng-update/v11/update-configs/update-configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Rule } from '@angular-devkit/schematics'; | ||
import { basename } from 'node:path'; | ||
|
||
/** | ||
* Update Otter cms.json in an Angular Project | ||
*/ | ||
export function updateEslintJsonFile(): Rule { | ||
const configFilePattern = /^.?eslint(:?rc)?\..*/; | ||
const toReplace = { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention -- following eslint config name | ||
'angular-template-recommended': /(['"](?:plugin:)?@o3r\/)template-recommended(['"])/g, | ||
// eslint-disable-next-line @typescript-eslint/naming-convention -- following eslint config name | ||
'monorepo-recommended': /(['"](?:plugin:)?@o3r\/)json-recommended(['"])/g | ||
}; | ||
|
||
return (tree) => { | ||
tree.visit((path) => { | ||
if (configFilePattern.test(basename(path))) { | ||
const content = tree.readText(path); | ||
const newContent = Object.entries(toReplace).reduce((acc, [rule, regexp]) => { | ||
return acc.replaceAll(regexp, `$1${rule}$2`); | ||
}, content); | ||
|
||
if (content !== newContent) { | ||
tree.overwrite(path, newContent); | ||
} | ||
} | ||
}); | ||
|
||
return tree; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters