Skip to content

Commit

Permalink
Merge branch 'trunk' into try/add-toggle-to-show-read-more-in-post-ex…
Browse files Browse the repository at this point in the history
…cerpt
  • Loading branch information
carolinan authored Feb 6, 2023
2 parents dca155d + b0f945d commit 7bd7665
Show file tree
Hide file tree
Showing 6,201 changed files with 303,772 additions and 172,866 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
File renamed without changes.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[*.{yml,yaml}]
indent_style = space
indent_size = 2

[*.{gradle,java,kt}]
indent_style = space

Expand Down
297 changes: 257 additions & 40 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
const { escapeRegExp } = require( 'lodash' );
const glob = require( 'glob' ).sync;
const { join } = require( 'path' );

Expand All @@ -17,7 +16,8 @@ const { version } = require( './package' );
* @type {string}
*/
const majorMinorRegExp =
escapeRegExp( version.replace( /\.\d+$/, '' ) ) + '(\\.\\d+)?';
version.replace( /\.\d+$/, '' ).replace( /[\\^$.*+?()[\]{}|]/g, '\\$&' ) +
'(\\.\\d+)?';

/**
* The list of patterns matching files used only for development purposes.
Expand All @@ -26,8 +26,8 @@ const majorMinorRegExp =
*/
const developmentFiles = [
'**/benchmark/**/*.js',
'**/@(__mocks__|__tests__|test)/**/*.js',
'**/@(storybook|stories)/**/*.js',
'**/@(__mocks__|__tests__|test)/**/*.[tj]s?(x)',
'**/@(storybook|stories)/**/*.[tj]s?(x)',
'packages/babel-preset-default/bin/**/*.js',
];

Expand All @@ -36,6 +36,162 @@ const typedFiles = glob( 'packages/*/package.json' )
.filter( ( fileName ) => require( join( __dirname, fileName ) ).types )
.map( ( fileName ) => fileName.replace( 'package.json', '**/*.js' ) );

const restrictedImports = [
{
name: 'framer-motion',
message:
'Please use the Framer Motion API through `@wordpress/components` instead.',
},
{
name: 'lodash',
importNames: [
'camelCase',
'capitalize',
'castArray',
'chunk',
'clamp',
'clone',
'cloneDeep',
'compact',
'concat',
'countBy',
'debounce',
'deburr',
'defaults',
'defaultTo',
'delay',
'difference',
'differenceWith',
'dropRight',
'each',
'escape',
'escapeRegExp',
'every',
'extend',
'filter',
'find',
'findIndex',
'findKey',
'findLast',
'first',
'flatMap',
'flatten',
'flattenDeep',
'flow',
'flowRight',
'forEach',
'fromPairs',
'has',
'identity',
'includes',
'invoke',
'isArray',
'isBoolean',
'isEqual',
'isFinite',
'isFunction',
'isMatch',
'isNil',
'isNumber',
'isObject',
'isObjectLike',
'isPlainObject',
'isString',
'isUndefined',
'keyBy',
'keys',
'last',
'lowerCase',
'map',
'mapKeys',
'maxBy',
'memoize',
'negate',
'noop',
'nth',
'omit',
'omitBy',
'once',
'orderby',
'overEvery',
'partial',
'partialRight',
'pick',
'pickBy',
'random',
'reduce',
'reject',
'repeat',
'reverse',
'setWith',
'size',
'snakeCase',
'some',
'sortBy',
'startCase',
'startsWith',
'stubFalse',
'stubTrue',
'sum',
'sumBy',
'take',
'throttle',
'times',
'toString',
'trim',
'truncate',
'unescape',
'unionBy',
'uniq',
'uniqBy',
'uniqueId',
'uniqWith',
'upperFirst',
'values',
'without',
'words',
'xor',
'zip',
],
message:
'This Lodash method is not recommended. Please use native functionality instead. If using `memoize`, please use `memize` instead.',
},
{
name: 'reakit',
message:
'Please use Reakit API through `@wordpress/components` instead.',
},
{
name: 'redux',
importNames: [ 'combineReducers' ],
message: 'Please use `combineReducers` from `@wordpress/data` instead.',
},
{
name: 'puppeteer-testing-library',
message: '`puppeteer-testing-library` is still experimental.',
},
{
name: '@emotion/css',
message:
'Please use `@emotion/react` and `@emotion/styled` in order to maintain iframe support. As a replacement for the `cx` function, please use the `useCx` hook defined in `@wordpress/components` instead.',
},
{
name: '@wordpress/edit-post',
message:
"edit-post is a WordPress top level package that shouldn't be imported into other packages",
},
{
name: '@wordpress/edit-site',
message:
"edit-site is a WordPress top level package that shouldn't be imported into other packages",
},
{
name: '@wordpress/edit-widgets',
message:
"edit-widgets is a WordPress top level package that shouldn't be imported into other packages",
},
];

module.exports = {
root: true,
extends: [
Expand Down Expand Up @@ -70,39 +226,7 @@ module.exports = {
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'framer-motion',
message:
'Please use the Framer Motion API through `@wordpress/components` instead.',
},
{
name: 'lodash',
importNames: [ 'memoize' ],
message: 'Please use `memize` instead.',
},
{
name: 'reakit',
message:
'Please use Reakit API through `@wordpress/components` instead.',
},
{
name: 'redux',
importNames: [ 'combineReducers' ],
message:
'Please use `combineReducers` from `@wordpress/data` instead.',
},
{
name: 'puppeteer-testing-library',
message:
'`puppeteer-testing-library` is still experimental.',
},
{
name: '@emotion/css',
message:
'Please use `@emotion/react` and `@emotion/styled` in order to maintain iframe support. As a replacement for the `cx` function, please use the `useCx` hook defined in `@wordpress/components` instead.',
},
],
paths: restrictedImports,
},
],
'@typescript-eslint/no-restricted-imports': [
Expand Down Expand Up @@ -194,7 +318,7 @@ module.exports = {
{
files: [ 'packages/react-native-*/**/*.js' ],
settings: {
'import/ignore': [ 'react-native' ], // Workaround for https://github.com/facebook/react-native/issues/28549
'import/ignore': [ 'react-native' ], // Workaround for https://github.com/facebook/react-native/issues/28549.
},
},
{
Expand Down Expand Up @@ -225,18 +349,71 @@ module.exports = {
},
},
{
files: [ 'packages/jest*/**/*.js' ],
files: [ 'packages/components/src/**/*.[tj]s?(x)' ],
excludedFiles: [ ...developmentFiles ],
rules: {
'react-hooks/exhaustive-deps': 'error',
},
},
{
files: [ 'packages/jest*/**/*.js', '**/test/**/*.js' ],
excludedFiles: [ 'test/e2e/**/*.js' ],
extends: [ 'plugin:@wordpress/eslint-plugin/test-unit' ],
},
{
files: [ '**/test/**/*.[tj]s?(x)' ],
excludedFiles: [
'**/*.@(android|ios|native).[tj]s?(x)',
'packages/react-native-*/**/*.[tj]s?(x)',
'test/native/**/*.[tj]s?(x)',
'test/e2e/**/*.[tj]s?(x)',
'test/storybook-playwright/**/*.[tj]s?(x)',
],
extends: [
'plugin:jest-dom/recommended',
'plugin:testing-library/react',
'plugin:jest/recommended',
],
},
{
files: [ 'packages/e2e-test*/**/*.js' ],
excludedFiles: [ 'packages/e2e-test-utils-playwright/**/*.js' ],
extends: [ 'plugin:@wordpress/eslint-plugin/test-e2e' ],
rules: {
'jest/expect-expect': 'off',
},
},
{
files: [ 'bin/**/*.js', 'packages/env/**' ],
files: [
'test/e2e/**/*.[tj]s',
'packages/e2e-test-utils-playwright/**/*.[tj]s',
],
extends: [ 'plugin:eslint-plugin-playwright/playwright-test' ],
rules: {
'@wordpress/no-global-active-element': 'off',
'@wordpress/no-global-get-selection': 'off',
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[callee.property.name="$"]',
message:
'`$` is discouraged, please use `locator` instead',
},
{
selector: 'CallExpression[callee.property.name="$$"]',
message:
'`$$` is discouraged, please use `locator` instead',
},
{
selector:
'CallExpression[callee.object.name="page"][callee.property.name="waitForTimeout"]',
message: 'Prefer page.locator instead.',
},
],
},
},
{
files: [ 'bin/**/*.js', 'bin/**/*.mjs', 'packages/env/**' ],
rules: {
'no-console': 'off',
},
Expand All @@ -248,5 +425,45 @@ module.exports = {
'jsdoc/valid-types': 'off',
},
},
{
files: [
'**/@(storybook|stories)/*',
'packages/components/src/**/*.tsx',
],
rules: {
// Useful to add story descriptions via JSDoc without specifying params,
// or in TypeScript files where params are likely already documented outside of the JSDoc.
'jsdoc/require-param': 'off',
},
},
{
files: [ 'packages/components/src/**' ],
excludedFiles: [ 'packages/components/src/**/@(test|stories)/**' ],
plugins: [ 'ssr-friendly' ],
extends: [ 'plugin:ssr-friendly/recommended' ],
},
{
files: [ 'packages/block-editor/**' ],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
...restrictedImports,
{
name: '@wordpress/api-fetch',
message:
"block-editor is a generic package that doesn't depend on a server or WordPress backend. To provide WordPress integration, consider passing settings to the BlockEditorProvider components.",
},
{
name: '@wordpress/core-data',
message:
"block-editor is a generic package that doesn't depend on a server or WordPress backend. To provide WordPress integration, consider passing settings to the BlockEditorProvider components.",
},
],
},
],
},
},
],
};
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# ESLint updates.
f63053cace3c02e284f00918e1854284c85b9132

# Prettier upgrade to 2.6.2.
33d84b036592a5bf31af05b7710f3b2b14163dc4
Loading

0 comments on commit 7bd7665

Please sign in to comment.