From 6c02b71515faf8ae1d1f50e6aac7b305c1b19143 Mon Sep 17 00:00:00 2001 From: zepumph Date: Thu, 21 May 2020 10:44:06 -0800 Subject: [PATCH] delete no-extend.js unused lint-rule, https://github.com/phetsims/phet-core/issues/71 --- eslint/.eslintrc.js | 1 - eslint/rules/no-extend.js | 59 --------------------------------------- 2 files changed, 60 deletions(-) delete mode 100644 eslint/rules/no-extend.js diff --git a/eslint/.eslintrc.js b/eslint/.eslintrc.js index c2e1feeb..8b92bd26 100644 --- a/eslint/.eslintrc.js +++ b/eslint/.eslintrc.js @@ -59,7 +59,6 @@ module.exports = { 'always' ], 'bad-text': 2, - 'no-extend': 0,// wait to turn this on until there are less usages, https://github.com/phetsims/phet-core/issues/71 // Custom rule for checking the copyright. copyright: 2, diff --git a/eslint/rules/no-extend.js b/eslint/rules/no-extend.js deleted file mode 100644 index ad4ad28d..00000000 --- a/eslint/rules/no-extend.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2019, University of Colorado Boulder - -/** - * Lint detector for invalid code based on its tokenized parts. - * This rule is currently hard coded for _.extend, but could be easily adapted for any code tokens. Currently this will only - * flag items that are in requirejs files (signified with a "define(" and then a "require" arg (see regex below). - * - * @author Michael Kauzmann (PhET Interactive Simulations) - */ - -/* eslint-env node */ -'use strict'; - -module.exports = context => { - - const badTextParts = [ '_', '.', 'extend' ]; - return { - meta: { - fixable: 'code' - }, - Program: node => { - const sourceCode = context.getSourceCode(); - const codeTokens = sourceCode.getTokens( node ); - - for ( let i = 0; i < codeTokens.length; i++ ) { - const token = codeTokens[ i ]; // {Token} - const failedTokens = []; - for ( let j = 0; j < badTextParts.length; j++ ) { - const badTextToken = badTextParts[ j ]; - const combinedIndex = i + j; - if ( combinedIndex < codeTokens.length && codeTokens[ combinedIndex ].value === badTextToken ) { - failedTokens.push( codeTokens[ combinedIndex ] ); - } - else { - break; - } - } - - // if they are the same - if ( failedTokens.map( token => token.value ).join( '' ) === badTextParts.join( '' ) && // if it matches - /^define\(.*require/m.test( sourceCode.text ) ) { // proxy for requirejs - context.report( { - loc: token.loc.start, - message: 'requirejs file contains _.extend, use merge instead', - fix: fixer => { - - // This hard coded fixer is meant for replacing _.extend with merge, see https://github.com/phetsims/phet-core/issues/71 - return fixer.replaceTextRange( [ failedTokens[ 0 ].start, failedTokens[ failedTokens.length - 1 ].end ], 'merge' ); - } - } ); - } - } - } - }; -}; - -module.exports.schema = [ - // JSON Schema for rule options goes here -]; \ No newline at end of file