File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 2323 "eslint-restricted-globals" : " ~0.2.0"
2424 },
2525 "devDependencies" : {
26- "@lwc/eslint-plugin-lwc" : " ^1.0 .0" ,
26+ "@lwc/eslint-plugin-lwc" : " ^1.1 .0" ,
2727 "@salesforce/eslint-plugin-lightning" : " ^0.1.0" ,
2828 "eslint" : " ^7.26.0" ,
2929 "eslint-plugin-import" : " ^2.23.2" ,
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ module.exports = {
113113 '@lwc/lwc/no-dupe-class-members' : 'error' ,
114114 '@lwc/lwc/no-inner-html' : 'error' ,
115115 '@lwc/lwc/no-leading-uppercase-api-name' : 'error' ,
116+ '@lwc/lwc/no-template-children' : 'error' ,
116117 '@lwc/lwc/prefer-custom-event' : 'error' ,
117118 '@lwc/lwc/valid-api' : [
118119 'error' ,
Original file line number Diff line number Diff line change @@ -110,6 +110,25 @@ describe('recommended config', () => {
110110 assert . strictEqual ( messages [ 0 ] . ruleId , '@lwc/lwc/no-attributes-during-construction' ) ;
111111 } ) ;
112112
113+ it ( 'should prevent accessing the immediate children of this.template' , ( ) => {
114+ const cli = getCliEngineWithRecommendedRules ( ) ;
115+
116+ const report = cli . executeOnText ( `
117+ import { LightningElement } from 'lwc';
118+
119+ export default class App extends LightningElement {
120+ renderedCallback() {
121+ const element = this.template.firstChild;
122+ element.focus();
123+ }
124+ }
125+ ` ) ;
126+
127+ const { messages } = report . results [ 0 ] ;
128+ assert . strictEqual ( messages . length , 1 ) ;
129+ assert . strictEqual ( messages [ 0 ] . ruleId , '@lwc/lwc/no-template-children' ) ;
130+ } ) ;
131+
113132 it ( 'should prevent invalid usage of Apex method' , ( ) => {
114133 const cli = getCliEngineWithRecommendedRules ( ) ;
115134
Original file line number Diff line number Diff line change 246246 resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz#87de7af9c231826fdd68ac7258f77c429e0e5fcf"
247247 integrity sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==
248248
249- " @lwc/eslint-plugin-lwc@^1.0 .0 " :
250- version "1.0.1 "
251- resolved "https://registry.yarnpkg.com/@lwc/eslint-plugin-lwc/-/eslint-plugin-lwc-1.0.1. tgz#6e8caf63d1ef60c26a609e8e9b836e1a5f454b14 "
252- integrity sha512-BtVlcIc+Fc/G61lM0jixFSr5XNY4w4YjWigSlNHA1+wBEe0VZ/ByJpUZnePrLfHM4lYCl9qOs8t/6c8ZqK1ghA ==
249+ " @lwc/eslint-plugin-lwc@^1.1 .0 " :
250+ version "1.1.0 "
251+ resolved "https://registry.yarnpkg.com/@lwc/eslint-plugin-lwc/-/eslint-plugin-lwc-1.1.0. tgz#e2c70252c4c52a3f66facca653f5f93e1dd66dc9 "
252+ integrity sha512-0oU9tDTX2qF9efmwhLKl5R4jJhZfU5gaHdtNiYxv0kqL5N22xxGO20+AV+ShLt4QocCO/wrq6RO+lnw0ZzqeTQ ==
253253 dependencies :
254254 minimatch "^3.0.4"
255255
You can’t perform that action at this time.
0 commit comments