All files / src/migrations 4.11.0.ts

100% Statements 13/13
100% Branches 0/0
100% Functions 5/5
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82  1x 1x   1x                                                                     1x 1x 1x       1x   1x             1x                                   1x 4x     1x 15x        
import { Rule, Tree } from '@angular-devkit/schematics';
import { JSONFile } from '../utils/angular/json-utils';
import { tryRule } from './utils/rules';
 
const manualProcess = `## This migrates upddates your tslint config with latest best practice.
 
to apply this changes apply the following steps:
 
#### Update project \`tslint.json\` to include the following configration
 
inside \`rules\` remove the following rules:
\`
- 'use-input-property-decorator'
- 'use-output-property-decorator'
- 'use-host-property-decorator'
- 'use-life-cycle-interface'
\`
 
and add the following rules:
\`
+ "component-class-suffix": true,
+ "contextual-lifecycle": true,
+ "directive-class-suffix": true,
+ "no-conflicting-lifecycle": true,
+ "no-host-metadata-property": true,
+ "no-input-rename": true,
+ "no-inputs-metadata-property": true,
+ "no-output-native": true,
+ "no-output-on-prefix": true,
+ "no-output-rename": true,
+ "no-outputs-metadata-property": true,
+ "template-banana-in-box": true,
+ "template-no-negated-async": true,
+ "use-lifecycle-interface": true,
+ "use-pipe-transform-interface": true
\`
 
`;
 
export default function (): Rule {
  return tryRule((tree: Tree) => {
    updateTslintConfig(tree);
  }, manualProcess);
 
  function updateTslintConfig(tree: Tree) {
    const tslint = new JSONFile(tree, './tslint.json');
 
    const toBeRemoved = [
      'use-input-property-decorator',
      'use-output-property-decorator',
      'use-host-property-decorator',
      'use-life-cycle-interface',
    ];
 
    const toBeAddedUpdated = [
      'component-class-suffix',
      'contextual-lifecycle',
      'directive-class-suffix',
      'no-conflicting-lifecycle',
      'no-host-metadata-property',
      'no-input-rename',
      'no-inputs-metadata-property',
      'no-output-native',
      'no-output-on-prefix',
      'no-output-rename',
      'no-outputs-metadata-property',
      'template-banana-in-box',
      'template-no-negated-async',
      'use-lifecycle-interface',
      'use-pipe-transform-interface',
    ];
 
    toBeRemoved.forEach((key) => {
      tslint.remove(['rules', key]);
    });
 
    toBeAddedUpdated.forEach((key) => {
      tslint.modify(['rules', key], true);
    });
  }
}