@angular-eslint/schematics
Advanced tools
Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3
@@ -33,3 +33,3 @@ "use strict"; | ||
utils_1.addESLintTargetToProject(schema.project, 'lint'), | ||
ensureRootESLintConfig(tree, rootESLintrcJsonPath), | ||
ensureRootESLintConfig(schema, tree, rootESLintrcJsonPath), | ||
convertTSLintDisableCommentsForProject(schema.project), | ||
@@ -41,3 +41,3 @@ isRootAngularProject | ||
? schematics_1.noop() | ||
: convertNonRootTSLintConfig(projectRoot, projectType, projectTSLintJsonPath, rootESLintrcJsonPath), | ||
: convertNonRootTSLintConfig(schema, projectRoot, projectType, projectTSLintJsonPath, rootESLintrcJsonPath), | ||
]); | ||
@@ -57,9 +57,9 @@ }; | ||
*/ | ||
function ensureRootESLintConfig(tree, rootESLintrcJsonPath) { | ||
function ensureRootESLintConfig(schema, tree, rootESLintrcJsonPath) { | ||
const hasExistingRootESLintrcConfig = tree.exists(rootESLintrcJsonPath); | ||
return hasExistingRootESLintrcConfig | ||
? schematics_1.noop() | ||
: convertRootTSLintConfig('tslint.json', rootESLintrcJsonPath); | ||
: convertRootTSLintConfig(schema, 'tslint.json', rootESLintrcJsonPath); | ||
} | ||
function convertRootTSLintConfig(rootTSLintJsonPath, rootESLintrcJsonPath) { | ||
function convertRootTSLintConfig(schema, rootTSLintJsonPath, rootESLintrcJsonPath) { | ||
return async (tree, context) => { | ||
@@ -82,2 +82,4 @@ const rawRootTSLintJson = utils_1.readJsonInTree(tree, rootTSLintJsonPath); | ||
removeUndesiredRulesFromConfig(convertedRootESLintConfig); | ||
adjustSomeRuleConfigs(convertedRootESLintConfig); | ||
handleFormattingRules(schema, context, convertedRootESLintConfig); | ||
/** | ||
@@ -162,3 +164,3 @@ * To avoid users' configs being bigger and more verbose than necessary, we perform some | ||
} | ||
function convertNonRootTSLintConfig(projectRoot, projectType, projectTSLintJsonPath, rootESLintrcJsonPath) { | ||
function convertNonRootTSLintConfig(schema, projectRoot, projectType, projectTSLintJsonPath, rootESLintrcJsonPath) { | ||
return async (tree, context) => { | ||
@@ -182,2 +184,4 @@ const rawProjectTSLintJson = utils_1.readJsonInTree(tree, projectTSLintJsonPath); | ||
removeUndesiredRulesFromConfig(convertedProjectESLintConfig); | ||
adjustSomeRuleConfigs(convertedProjectESLintConfig); | ||
handleFormattingRules(schema, context, convertedProjectESLintConfig); | ||
/** | ||
@@ -310,13 +314,47 @@ * To avoid users' configs being bigger and more verbose than necessary, we perform some | ||
} | ||
function removeUndesiredRulesFromConfig(convertedConfig) { | ||
function handleFormattingRules(schema, context, convertedConfig) { | ||
if (!convertedConfig.rules) { | ||
return; | ||
} | ||
delete convertedConfig.rules['@typescript-eslint/tslint/config']; | ||
if (!schema.convertIndentationRules) { | ||
delete convertedConfig.rules['@typescript-eslint/indent']; | ||
return; | ||
} | ||
/** | ||
* We really don't want to continue the practice of using a linter | ||
* We really don't want to encourage the practice of using a linter | ||
* for formatting concerns. Please use prettier y'all! | ||
*/ | ||
delete convertedConfig.rules['@typescript-eslint/indent']; | ||
if (convertedConfig.rules['@typescript-eslint/indent']) { | ||
context.logger.warn(`\nWARNING: You are currently using a linting rule to deal with indentation. Linters are not well suited to purely code formatting concerns, such as indentation.`); | ||
context.logger.warn('\nPer your instructions we have migrated your TSLint indentation configuration to its equivalent in ESLint, but we strongly recommend switching to a dedicated code formatter such as https://prettier.io\n'); | ||
} | ||
} | ||
function adjustSomeRuleConfigs(convertedConfig) { | ||
if (!convertedConfig.rules) { | ||
return; | ||
} | ||
/** | ||
* Adjust the quotes rule to always add allowTemplateLiterals as it is most common and can | ||
* always be removed by the user if undesired in their case. | ||
*/ | ||
if (convertedConfig.rules['@typescript-eslint/quotes']) { | ||
if (!Array.isArray(convertedConfig.rules['@typescript-eslint/quotes'])) { | ||
convertedConfig.rules['@typescript-eslint/quotes'] = [ | ||
convertedConfig.rules['@typescript-eslint/quotes'], | ||
'single', | ||
]; | ||
} | ||
if (!convertedConfig.rules['@typescript-eslint/quotes'][2]) { | ||
convertedConfig.rules['@typescript-eslint/quotes'].push({ | ||
allowTemplateLiterals: true, | ||
}); | ||
} | ||
} | ||
} | ||
function removeUndesiredRulesFromConfig(convertedConfig) { | ||
if (!convertedConfig.rules) { | ||
return; | ||
} | ||
delete convertedConfig.rules['@typescript-eslint/tslint/config']; | ||
/** | ||
* BOTH OF THESE RULES CREATE A LOT OF NOISE ON OOTB POLYFILLS.TS | ||
@@ -339,3 +377,2 @@ */ | ||
*/ | ||
delete convertedConfig.rules['@typescript-eslint/quotes']; | ||
delete convertedConfig.rules['no-restricted-imports']; | ||
@@ -342,0 +379,0 @@ /** |
@@ -21,4 +21,9 @@ { | ||
"x-prompt": "Which project would you like to convert from TSLint to ESLint?" | ||
}, | ||
"convertIndentationRules": { | ||
"description": "Whether or not rules relating purely to indentation (code formatting) should be converted. It is strongly encouraged to switch to https://prettier.io instead.", | ||
"type": "boolean", | ||
"default": false | ||
} | ||
} | ||
} |
{ | ||
"name": "@angular-eslint/schematics", | ||
"version": "2.0.0-alpha.2", | ||
"version": "2.0.0-alpha.3", | ||
"description": "Angular Schematics for angular-eslint", | ||
@@ -28,4 +28,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@angular-eslint/eslint-plugin": "2.0.0-alpha.2", | ||
"@angular-eslint/eslint-plugin-template": "2.0.0-alpha.2", | ||
"@angular-eslint/eslint-plugin": "2.0.0-alpha.3", | ||
"@angular-eslint/eslint-plugin-template": "2.0.0-alpha.3", | ||
"strip-json-comments": "3.1.1", | ||
@@ -45,3 +45,3 @@ "tslint-to-eslint-config": "2.2.0" | ||
}, | ||
"gitHead": "e5d58a3f47e2d5508bbf9c08139d0be73c5525dc" | ||
"gitHead": "8389aca91ad55280c4892ba64d5f49b514c040d9" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61690
1341
+ Added@angular-eslint/eslint-plugin@2.0.0-alpha.3(transitive)
+ Added@angular-eslint/eslint-plugin-template@2.0.0-alpha.3(transitive)
- Removed@angular-eslint/eslint-plugin@2.0.0-alpha.2(transitive)
- Removed@angular-eslint/eslint-plugin-template@2.0.0-alpha.2(transitive)