Skip to content

Commit

Permalink
add keyword-spacing to lint rules, phetsims/phet-info#156
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Feb 26, 2021
1 parent 67ad497 commit 9d5f6c0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
11 changes: 11 additions & 0 deletions eslint/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ module.exports = {
// enforces spacing between keys and values in object literal properties
'key-spacing': [ 'error', { beforeColon: false, afterColon: true } ],

// require a space before & after certain keywords
'keyword-spacing': [ 'error', {
before: true,
after: true,
overrides: {
case: { after: true }, // default
switch: { after: false },
catch: { after: false }
}
} ],

// require or disallow an empty line between class members
// https://eslint.org/docs/rules/lines-between-class-members
'lines-between-class-members': [ 'error', 'always', { exceptAfterSingleLine: false } ],
Expand Down
11 changes: 0 additions & 11 deletions eslint/format_eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,6 @@ module.exports = {
// https://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': [ 'off', 'prefer-double' ],

// require a space before & after certain keywords
'keyword-spacing': [ 'error', {
before: true,
after: true,
overrides: {
return: { after: true },
throw: { after: true },
case: { after: true }
}
} ],

// enforce position of line comments
// https://eslint.org/docs/rules/line-comment-position
// TODO: enable?
Expand Down
12 changes: 6 additions & 6 deletions eslint/rules/dispose.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ module.exports = function( context ) {
node.expression.callee.property.name ) {
const calleeName = node.expression.callee.property.name;
for ( const key in OBSERVER_REGISTRATIONS ) {
if( OBSERVER_REGISTRATIONS.hasOwnProperty( key ) ) {
if( calleeName === OBSERVER_REGISTRATIONS[ key ] ) {
if ( OBSERVER_REGISTRATIONS.hasOwnProperty( key ) ) {
if ( calleeName === OBSERVER_REGISTRATIONS[ key ] ) {
// we have found an observer registration, start at the root and look through its tokens for dispose
let disposeFound = false;
const rootNode = context.getSourceCode().ast;
if( rootNode &&
if ( rootNode &&
rootNode.tokens ) {
rootNode.tokens.forEach( function( token ) {
if( token ) {
if( token.type === 'Identifier' &&
if ( token ) {
if ( token.type === 'Identifier' &&
token.value === 'dispose' ) {
// we have found a dispose function
disposeFound = true;
}
}
} );
}
if( !disposeFound ) {
if ( !disposeFound ) {
context.report( {
node: node,
loc: node.loc.start,
Expand Down
2 changes: 1 addition & 1 deletion js/grunt/getDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = async function( repo ) {
sha = ( await execute( 'git', [ 'rev-parse', 'HEAD' ], { cwd: `../${dependency}` } ) ).trim();
branch = ( await execute( 'git', [ 'rev-parse', '--abbrev-ref', 'HEAD' ], { cwd: `../${dependency}` } ) ).trim();
}
catch ( e ) {
catch( e ) {
// We support repos that are not git repositories, see https://github.com/phetsims/chipper/issues/1011
console.log( `Did not find git information for ${dependency}` );
}
Expand Down

0 comments on commit 9d5f6c0

Please sign in to comment.