Code Monkey home page Code Monkey logo

js-coding-standards's Introduction

WebDevStudios. WordPress for big brands.

WebDevStudios JavaScript Coding Standards


This package is DEPRECATED and no longer in use at WebDevStudios and will no longer be maintained.


How to Install

npm install @webdevstudios/js-coding-standards --save-dev

In your package.json, you can add:

"eslintConfig": {
    "extends": "@webdevstudios/js-coding-standards"
}

To modify package.json quickly using jq use:

echo $( npx jq '.eslintConfig = {"extends": "@webdevstudios/js-coding-standards"}' package.json ) | npx jq . > package-tmp.json && mv package-tmp.json package.json 

Changelog

js-coding-standards's People

Contributors

aubreypwd avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

js-coding-standards's Issues

Bump eslint-plugin to >3.0

https://github.com/WebDevStudios/eslint-config-js-coding-standards/blob/master/package.json#L21


@michealengland had an issue where he was getting the error:

Oops! Something went wrong! :(
ESLint: 7.20.0
TypeError: Cannot read property 'name' of undefined
Occurred while linting /Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/src/blocks/three-column-post-cards/post-search-input/index.js:451
    at /Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/node_modules/@wordpress/eslint-plugin/rules/no-base-control-with-label-without-id.js:11:29
    at Array.some (<anonymous>)
    at containsAttribute (/Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/node_modules/@wordpress/eslint-plugin/rules/no-base-control-with-label-without-id.js:10:29)
    at JSXOpeningElement[name.name='BaseControl'] (/Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/node_modules/@wordpress/eslint-plugin/rules/no-base-control-with-label-without-id.js:15:6)
    at /Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/node_modules/eslint/lib/linter/node-event-generator.js:256:26)
    at NodeEventGenerator.applySelectors (/Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/node_modules/eslint/lib/linter/node-event-generator.js:285:22)
    at NodeEventGenerator.enterNode (/Users/mikeengland/Local Sites/care/app/public/wp-content/plugins/care-blocks/node_modules/eslint/lib/linter/node-event-generator.js:299:14)

When running node_modules/.bin/eslint...

When troubleshooting we found the same issue here:

WordPress/gutenberg#17043

And solved the issue by bumping @wordpress/eslint-plugin first to ^8.0 and then to ~3.0 which both resolved the issue.. So we should try and widen the range of @wordpress/eslint-plugin to something that auto-updates a bit more gracefully.

Require arrays to be on new lines

		/**
		 * Each element of an array requires new line.
		 *
		 * @since Tuesday, 10/13/2020
		 *
		 * @see  https://eslint.org/docs/rules/array-element-newline
		 * @report Error
		 */
		'array-element-newline': [
			'error',
			'always',
		],

Example:

const a = [ 'one', 'two' ];

Would have to be:

const a = [ 
	'one', 
	'two',
];

This makes groking array's easier and ordering easier.

Need to update eslint to version @7 because @6 causes issues for VSCode not being able to find e.g. @wordpress/eslint-plugin

image

As you can see in the screenshot we have a project (usually at the wp-content level) open with a theme (wd_s) in the project. wd_s has it's own .eslintrc file that uses js-coding-standards. But eslint@6 (which comes from our coding standards) seems to have issues finding modules in the theme folder, and ultimately in the project folder. In the theme, if you install eslint@7 the problem is resolved and the theme eslint is able to find @wordpress/eslint-plugin in the nested theme/*/node_modules/* folder.

eslint encorcing a max-width

image

image

const accordionHeader = accordion.querySelector( '.accordion-item-header' );
		const accordionHeader = accordion.querySelector(
			'.accordion-item-header'
		);

eslint conflicting with prettier rule

eslintprettier

			// If we're clicking on this accordion...
			if ( content.previousElementSibling === targetParent ) {
				// If it's already opened, close it. Otherwise, open it!
				if ( 'false' === content.getAttribute( 'aria-hidden' ) ) {
					content.setAttribute( 'aria-hidden', 'true' );
					content.parentElement.classList.remove( 'open' );
				} else {
					content.setAttribute( 'aria-hidden', 'false' );
					content.parentElement.classList.add( 'open' );
				}
			} else {
				content.setAttribute( 'aria-hidden', 'true' );
				content.parentElement.classList.remove( 'open' );
			}
		} );

Sync with php-coding-standards

There are a lot of rules, such as @since, @author and @return that are not required in JS docblocks, etc. I wonder if maybe there are more like this that need to be synced up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.