Skip to content

Commit 74e55bc

Browse files
authored
refactor: config prettier (#2042)
* refactor prettier and delete redundant prettier/editor config code * chore: format existing code * fix: missing formatting for block editor-utils and related formatting * add cs * correctly get eslint to respect prettier
1 parent 6eeedd2 commit 74e55bc

File tree

165 files changed

+33038
-33006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+33038
-33006
lines changed

.changeset/brown-flies-notice.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@faustwp/block-editor-utils': patch
3+
'@faustwp/core': patch
4+
'@faustwp/cli': patch
5+
---
6+
7+
Updated code formatting config and switch to tabs. Configure your editor config settings for tab sizing preferences.

.editorconfig

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
# Stop the editor from looking for .editorconfig files in the parent directories
12
root = true
23

34
[*]
5+
# Non-configurable Prettier behaviors
46
charset = utf-8
5-
end_of_line = lf
6-
indent_style = tab
77
insert_final_newline = true
8+
# Caveat: Prettier won’t trim trailing whitespace inside template strings, but your editor might.
89
trim_trailing_whitespace = true
9-
indent_size = 4
1010

11-
[{*.yml,package.json,*.md,*.tsx,*.ts,*.js,*.jsx}]
11+
# Configurable Prettier behaviors
12+
# (change these if your Prettier config differs)
13+
end_of_line = lf
14+
indent_style = tab
1215
indent_size = 2
16+
max_line_length = 80
17+
18+
[*.{yaml,yml}]
19+
# YAML files should use spaces, not tabs
1320
indent_style = space
21+
indent_size = 2

.eslintrc.js

Lines changed: 91 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,92 @@
11
module.exports = {
2-
root: true,
3-
env: {
4-
browser: true,
5-
es6: true,
6-
node: true,
7-
amd: true,
8-
},
9-
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
10-
extends: [
11-
'plugin:@typescript-eslint/eslint-recommended',
12-
'plugin:@typescript-eslint/recommended',
13-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
14-
'airbnb',
15-
'airbnb-typescript',
16-
'airbnb/hooks',
17-
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
18-
],
19-
parserOptions: {
20-
tsconfigRootDir: __dirname,
21-
project: './tsconfig.json',
22-
ecmaFeatures: {
23-
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
24-
sourceType: 'module', // Allows for the use of imports
25-
jsx: true,
26-
},
27-
},
28-
plugins: ['import', 'simple-import-sort', 'react', 'react-hooks'],
29-
rules: {
30-
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
31-
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
32-
'@typescript-eslint/unbound-method': 0,
33-
'@typescript-eslint/no-explicit-any': 0,
34-
'@typescript-eslint/no-unsafe-call': 0,
35-
'@typescript-eslint/no-unsafe-return': 0,
36-
'@typescript-eslint/no-unsafe-argument': 0,
37-
'@typescript-eslint/restrict-template-expressions': 0,
38-
'no-void': 0,
39-
'import/named': 0,
40-
'import/no-extraneous-dependencies': [
41-
'error',
42-
{
43-
devDependencies: [
44-
'jest.setup.ts',
45-
'**/__tests__/*',
46-
'**/*.test.ts',
47-
'**/*.test.tsx',
48-
],
49-
},
50-
],
51-
'import/prefer-default-export': 0,
52-
'react/jsx-closing-bracket-location': 0,
53-
'react/jsx-props-no-spreading': ['error', { html: 'ignore' }],
54-
'react/jsx-wrap-multilines': [
55-
'error',
56-
{ declaration: false, assignment: false },
57-
],
58-
'react/prop-types': 0,
59-
'react/require-default-props': 0,
60-
'@typescript-eslint/no-unsafe-assignment': 0,
61-
'@typescript-eslint/no-unsafe-member-access': 0,
62-
'jsx-a11y/anchor-is-valid': 0,
63-
'no-console': ['error', { allow: ['warn', 'error', 'debug'] }],
64-
'no-underscore-dangle': ['error', { 'allow': ['__schema'] }],
65-
'import/extensions': ['error', 'always'],
66-
},
67-
settings: {
68-
react: {
69-
createClass: 'createReactClass', // Regex for Component Factory to use,
70-
// default to "createReactClass"
71-
pragma: 'React', // Pragma to use, default to "React"
72-
version: '17.0', // React version. "detect" automatically picks the version you have installed.
73-
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
74-
// default to latest and warns if missing
75-
// It will default to "detect" in the future
76-
},
77-
},
78-
ignorePatterns: [
79-
'**/test/*',
80-
'**/tests/*',
81-
'.prettierrc.js',
82-
'jest.config.js',
83-
'jest.setup.ts',
84-
'utils.d.ts',
85-
'utils.js',
86-
'.eslintrc.js',
87-
'**/dist/*',
88-
'**/*.d.ts',
89-
'examples/**/*'
90-
],
91-
};
2+
root: true,
3+
env: {
4+
browser: true,
5+
es6: true,
6+
node: true,
7+
amd: true,
8+
},
9+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
10+
extends: [
11+
'plugin:@typescript-eslint/eslint-recommended',
12+
'plugin:@typescript-eslint/recommended',
13+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
14+
'airbnb',
15+
'airbnb-typescript',
16+
'airbnb/hooks',
17+
'prettier', // Enables eslint-config-prettier. Make sure this is always the last configuration in the extends array.
18+
],
19+
parserOptions: {
20+
tsconfigRootDir: __dirname,
21+
project: './tsconfig.json',
22+
ecmaFeatures: {
23+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
24+
sourceType: 'module', // Allows for the use of imports
25+
jsx: true,
26+
},
27+
},
28+
plugins: ['import', 'simple-import-sort', 'react', 'react-hooks'],
29+
rules: {
30+
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
31+
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
32+
'@typescript-eslint/unbound-method': 0,
33+
'@typescript-eslint/no-explicit-any': 0,
34+
'@typescript-eslint/no-unsafe-call': 0,
35+
'@typescript-eslint/no-unsafe-return': 0,
36+
'@typescript-eslint/no-unsafe-argument': 0,
37+
'@typescript-eslint/restrict-template-expressions': 0,
38+
'no-void': 0,
39+
'import/named': 0,
40+
'import/no-extraneous-dependencies': [
41+
'error',
42+
{
43+
devDependencies: [
44+
'jest.setup.ts',
45+
'**/__tests__/*',
46+
'**/*.test.ts',
47+
'**/*.test.tsx',
48+
],
49+
},
50+
],
51+
'import/prefer-default-export': 0,
52+
'react/jsx-closing-bracket-location': 0,
53+
'react/jsx-props-no-spreading': ['error', { html: 'ignore' }],
54+
'react/jsx-wrap-multilines': [
55+
'error',
56+
{ declaration: false, assignment: false },
57+
],
58+
'react/prop-types': 0,
59+
'react/require-default-props': 0,
60+
'@typescript-eslint/no-unsafe-assignment': 0,
61+
'@typescript-eslint/no-unsafe-member-access': 0,
62+
'jsx-a11y/anchor-is-valid': 0,
63+
'no-console': ['error', { allow: ['warn', 'error', 'debug'] }],
64+
'no-underscore-dangle': ['error', { allow: ['__schema'] }],
65+
'import/extensions': ['error', 'always'],
66+
'arrow-body-style': 0,
67+
},
68+
settings: {
69+
react: {
70+
createClass: 'createReactClass', // Regex for Component Factory to use,
71+
// default to "createReactClass"
72+
pragma: 'React', // Pragma to use, default to "React"
73+
version: '17.0', // React version. "detect" automatically picks the version you have installed.
74+
// You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
75+
// default to latest and warns if missing
76+
// It will default to "detect" in the future
77+
},
78+
},
79+
ignorePatterns: [
80+
'**/test/*',
81+
'**/tests/*',
82+
'.prettierrc.js',
83+
'jest.config.js',
84+
'jest.setup.ts',
85+
'utils.d.ts',
86+
'utils.js',
87+
'.eslintrc.js',
88+
'**/dist/*',
89+
'**/*.d.ts',
90+
'examples/**/*',
91+
],
92+
};

.prettierrc.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ module.exports = {
22
arrowParens: 'always',
33
bracketSameLine: true,
44
singleQuote: true,
5-
tabWidth: 2,
65
semi: true,
76
trailingComma: 'all',
8-
endOfLine: 'lf',
9-
useTabs: false,
107
};

0 commit comments

Comments
 (0)