Skip to content
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
28 changes: 28 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#####
# Files and directories to ignore if the repository is installed as a Composer package.
#
# File and directory paths for the plugin's own build process are managed via `package.json:files`.
#####

## Directories
/.git
/.github
/.lefthook.yml
/docs
/packages
/tests

## Files
.*
CHANGELOG.md
composer.json
composer.lock
package.json
package-lock.json
phpstan.neon.dist
phpunit.xml.dist
README.md
readme.txt
tsconfig.base.json
tsconfig.json
webpack.config.js
9 changes: 1 addition & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,12 @@ insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[*.json]
indent_size = 2

[*.md]
[*.{md,txt}]
trim_trailing_whitespace = false
indent_style = space
indent_size = 2

[*.txt]
trim_trailing_whitespace = false

[*.{yml,yaml}]
insert_final_newline = false
quote_type = single
indent_style = space
indent_size = 2
7 changes: 4 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/*.min.js
**/node_modules/**
**/vendor/**
**/build/**
build/**
node_modules/**
tests/_output/**
vendor/**
158 changes: 158 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
module.exports = {
root: true,
extends: [ 'plugin:@wordpress/eslint-plugin/recommended' ],
plugins: [ 'import', 'jest' ],
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
project: './tsconfig.json',
},
settings: {
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
},
env: {
browser: true,
es6: true,
node: true,
},
rules: {
// React best practices
'react/jsx-boolean-value': 'error',
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never' },
],

// WordPress-specific rules, lifted from gutenberg
'@wordpress/dependency-group': 'error',
'@wordpress/data-no-store-string-literals': 'error',
'@wordpress/wp-global-usage': 'error',
'@wordpress/react-no-unsafe-timeout': 'error',
'@wordpress/i18n-hyphenated-range': 'error',
'@wordpress/i18n-no-flanking-whitespace': 'error',
'@wordpress/i18n-text-domain': [
'error',
{
allowedTextDomain: 'onesearch',
},
],
'@wordpress/no-unsafe-wp-apis': 'off',
'import/default': 'error',
'import/named': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.@(spec|test).@(j|t)s?(x)',
'**/@(webpack|jest|babel|playwright).config.@(j|t)s',
'**/scripts/**',
'**/tests/**',
],
},
],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'lodash',
message: 'Please use native functionality instead.',
},
{
name: 'classnames',
message:
"Please use `clsx` instead. It's a lighter and faster drop-in replacement for `classnames`.",
},
{
name: 'redux',
importNames: [ 'combineReducers' ],
message:
'Please use `combineReducers` from `@wordpress/data` instead.',
},
],
},
],
'no-restricted-syntax': [
'error',
{
selector:
'ImportDeclaration[source.value=/^@wordpress\\u002F.+\\u002F/]',
message:
'Path access on WordPress dependencies is not allowed.',
},
{
selector: 'JSXAttribute[name.name="id"][value.type="Literal"]',
message:
'Do not use string literals for IDs; use withInstanceId instead.',
},
{
selector:
'CallExpression[callee.object.name="Math"][callee.property.name="random"]',
message:
"Do not use Math.random() to generate unique IDs; use withInstanceId instead. (If you're not generating unique IDs: ignore this message.)",
},
],
},
overrides: [
{
files: [ '**/*.ts?(x)' ],
rules: {
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: false,
},
],
'@typescript-eslint/no-shadow': 'error',
'dot-notation': 'off',
'no-shadow': 'off',
'jsdoc/require-param': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-type': 'off',
},
},

// Jest testing rules for test files
{
files: [
'**/__tests__/**/*.{ts,tsx}',
'**/*.{test,spec}.{ts,tsx}',
'tests/js/**/*.{ts,tsx}',
],
env: {
jest: true,
},
extends: [ 'plugin:jest/recommended' ],
parserOptions: {
project: './tests/js/tsconfig.json',
},
rules: {
'jest/expect-expect': 'error',
'jest/no-commented-out-tests': 'warn',
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
},
},

// Playwright E2E tests
{
files: [ 'tests/e2e/**/*.{ts,tsx}' ],
parserOptions: {
project: null,
},
rules: {
'jsdoc/no-undefined-types': 'off',
},
},
],
};
74 changes: 0 additions & 74 deletions .eslintrc.json

This file was deleted.

33 changes: 33 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Automatically normalize line endings.
* text=auto

# Files and directories to exclude from `composer require`.
/.github export-ignore
/.wordpress-org export-ignore
/src export-ignore
/tests/ export-ignore

# Don't include the dotfiles for distribution.
/.* export-ignore

# Root files that are not needed for distribution.
/babel.config.js export-ignore
/blueprint.json export-ignore
/composer.lock export-ignore
/package-lock.json export-ignore
/package.json export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/playwright.config.ts export-ignore
/release-please-config.json export-ignore
/tsconfig.base.json export-ignore
/tsconfig.json export-ignore
/webpack.config.js export-ignore

# Mark docs as documentation for GitHub Linguist.
/docs/ linguist-documentation export-ignore
/CHANGELOG.md export-ignore

# Keep license and readme files.
/LICENSE.md linguist-documentation
/README.md linguist-documentation
34 changes: 34 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Codecov configuration
# https://docs.codecov.com/docs/codecov-yaml

# Fix path prefixes from Docker container paths to repo-relative paths
fixes:
- '/var/www/html/wp-content/plugins/onesearch'

coverage:
status:
project:
default:
target: 70%
threshold: 5%
informational: true
patch:
default:
target: 60%
informational: true

ignore:
- 'tests/**'
- '**/*.test.ts'
- '**/*.test.tsx'
- '**/*.spec.ts'
- '**/*.spec.tsx'
- '**/types.d.ts'
- 'playwright.config.ts'

comment:
layout: 'reach,diff,flags,files'
behavior: default
require_base: false
require_head: true
require_changes: true
Loading
Loading