Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint: Add new rules #616

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
"FileReader": true,
"FontFace": true
},
"rules": {
"@wordpress/dependency-group": "error",
"@wordpress/i18n-text-domain": [
"error",
{
"allowedTextDomain": "create-block-theme"
}
],
"react/jsx-boolean-value": "error"
},
"overrides": [
{
"files": [ "**/test/**/*.js" ],
Expand Down
6 changes: 6 additions & 0 deletions src/editor-sidebar/create-panel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
Expand All @@ -21,6 +24,9 @@
} from '@wordpress/components';
import { addCard, copy } from '@wordpress/icons';

/**
* Internal dependencies
*/
import ScreenHeader from './screen-header';

export const CreateThemePanel = ( { createType } ) => {
Expand Down Expand Up @@ -48,7 +54,7 @@
)
: '',
} );
}, [] );

Check warning on line 57 in src/editor-sidebar/create-panel.js

View workflow job for this annotation

GitHub Actions / Lint

React Hook useSelect has a missing dependency: 'theme'. Either include it or remove the dependency array. You can also do a functional update 'setTheme(t => ...)' if you only need 'theme' in the 'setTheme' call

const cloneTheme = () => {
if ( createType === 'createClone' ) {
Expand Down
8 changes: 7 additions & 1 deletion src/editor-sidebar/create-variation-panel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { useDispatch } from '@wordpress/data';
Expand All @@ -16,8 +19,11 @@ import {
TextControl,
} from '@wordpress/components';
import { copy } from '@wordpress/icons';
import { postCreateThemeVariation } from '../resolvers';

/**
* Internal dependencies
*/
import { postCreateThemeVariation } from '../resolvers';
import ScreenHeader from './screen-header';

export const CreateVariationPanel = () => {
Expand Down
17 changes: 14 additions & 3 deletions src/editor-sidebar/json-editor-modal.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
/**
* External dependencies
*/
import CodeMirror from '@uiw/react-codemirror';
import { json } from '@codemirror/lang-json';

/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { useState, useEffect } from '@wordpress/element';
import { Modal } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import CodeMirror from '@uiw/react-codemirror';
import { json } from '@codemirror/lang-json';

/**
* Internal dependencies
*/
import { fetchThemeJson } from '../resolvers';

const ThemeJsonEditorModal = ( { onRequestClose } ) => {
Expand Down Expand Up @@ -34,7 +45,7 @@ const ThemeJsonEditorModal = ( { onRequestClose } ) => {
extensions={ [ json() ] }
value={ themeData }
onChange={ handleSave }
readOnly={ true }
readOnly
/>
</Modal>
);
Expand Down
9 changes: 8 additions & 1 deletion src/editor-sidebar/metadata-editor-modal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { useSelect, useDispatch } from '@wordpress/data';
Expand All @@ -15,6 +18,10 @@ import {
TextareaControl,
ExternalLink,
} from '@wordpress/components';

/**
* Internal dependencies
*/
import { postUpdateThemeMetadata } from '../resolvers';

export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
Expand Down Expand Up @@ -92,7 +99,7 @@ export const ThemeMetadataEditorModal = ( { onRequestClose } ) => {
</Text>
<Spacer />
<TextControl
disabled={ true }
disabled
label={ __( 'Theme name', 'create-block-theme' ) }
value={ theme.name }
/>
Expand Down
6 changes: 6 additions & 0 deletions src/editor-sidebar/save-panel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as noticesStore } from '@wordpress/notices';
Expand All @@ -16,6 +19,9 @@ import {
import { archive } from '@wordpress/icons';
import { store as preferencesStore } from '@wordpress/preferences';

/**
* Internal dependencies
*/
import ScreenHeader from './screen-header';

const PREFERENCE_SCOPE = 'create-block-theme';
Expand Down
3 changes: 3 additions & 0 deletions src/editor-sidebar/screen-header.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* WordPress dependencies
*/
import {
// eslint-disable-next-line
__experimentalHStack as HStack,
Expand Down
6 changes: 6 additions & 0 deletions src/plugin-sidebar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';
import { registerPlugin } from '@wordpress/plugins';
import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/edit-site';
Expand Down Expand Up @@ -39,6 +42,9 @@ import {
blockMeta,
} from '@wordpress/icons';

/**
* Internal dependencies
*/
import { CreateThemePanel } from './editor-sidebar/create-panel';
import ThemeJsonEditorModal from './editor-sidebar/json-editor-modal';
import { SaveThemePanel } from './editor-sidebar/save-panel';
Expand Down
3 changes: 3 additions & 0 deletions src/resolvers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* WordPress dependencies
*/
import apiFetch from '@wordpress/api-fetch';

export async function fetchThemeJson() {
Expand Down
3 changes: 3 additions & 0 deletions src/wp-org-theme-directory.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* WordPress dependencies
*/
import apiFetch from '@wordpress/api-fetch';

async function loadUnavailableThemeNames() {
Expand Down
4 changes: 4 additions & 0 deletions update-version-and-changelog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/* eslint-disable no-console */

/**
* External dependencies
*/
const fs = require( 'fs' );
const core = require( '@actions/core' );
const simpleGit = require( 'simple-git' );
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* WordPress Dependencies
* WordPress dependencies
*/
const defaultConfig = require( '@wordpress/scripts/config/webpack.config.js' );

Expand Down
Loading