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

build: configure ESLint for JSDoc types #249

Merged
merged 1 commit into from
Apr 7, 2023
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
18 changes: 17 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,26 @@
* ESLint presets
*/
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
project: [ './jsconfig.json', 'jsconfig.eslint.json' ],
},
extends: [ 'plugin:@wordpress/eslint-plugin/recommended' ],
settings: {
'import/parsers': {
'@typescript-eslint/parser': [ '.js', '.jsx', '.ts', '.tsx' ],
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: [ './jsconfig.json', 'jsconfig.eslint.json' ],
},
},
},
env: {
browser: true,
es2021: true,
jest: true,
},
extends: ['plugin:@wordpress/eslint-plugin/recommended'],
};
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Import the default config file and expose it in the project root.
// Useful for editor integrations.
module.exports = require('@wordpress/prettier-config');
module.exports = require( '@wordpress/prettier-config' );
6 changes: 3 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = (api) => {
api.cache(true);
module.exports = ( api ) => {
api.cache( true );

return {
presets: ['@wordpress/babel-preset-default'],
presets: [ '@wordpress/babel-preset-default' ],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most the configs didn't follow the linting rules.

};
};
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const jestConfig = {
verbose: true,
preset: '@wordpress/jest-preset-default',
setupFilesAfterEnv: ['expect-puppeteer'],
setupFilesAfterEnv: [ 'expect-puppeteer' ],
projects: [
{
displayName: 'unit',
testMatch: ['<rootDir>/tests/jsunit/**/*.test.js'],
testMatch: [ '<rootDir>/tests/jsunit/**/*.test.js' ],
},
{
displayName: 'e2e',
preset: 'jest-puppeteer',
testMatch: ['<rootDir>/tests/jse2e/**/*.test.js'],
testMatch: [ '<rootDir>/tests/jse2e/**/*.test.js' ],
},
],
};
Expand Down
13 changes: 13 additions & 0 deletions jsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"noEmit": true,
"allowJs": true
},
"include": [
".eslintrc.js",
".prettierrc.js",
"babel.config.js",
"jest.config.js",
"webpack.config.js"
]
Comment on lines +6 to +12
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
12 changes: 7 additions & 5 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"compilerOptions": {
"checkJs": true,
"types": ["jest"]
},
"include": ["**/*.js"]
"compilerOptions": {
"checkJs": true,
"types": [ "jest" ],
"baseUrl": "./src"
},
"include": [ "./src/**/*.js", "./src/**/*.jsx" ],
"exclude": [ "./node_modules" ]
}
175 changes: 175 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@wordpress/icons": "^9.21.0",
"@wordpress/scripts": "^26.1.0",
"classnames": "^2.3.2",
"eslint-import-resolver-typescript": "^3.5.5",
"husky": "^8.0.3",
"jest-puppeteer": "^6.2.0",
"lint-staged": "^13.2.0",
Expand Down
6 changes: 3 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const path = require('path');
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const path = require( 'path' );

module.exports = {
...defaultConfig,
entry: { 'wp-notify': path.resolve(process.cwd(), `src/wp-notify.js`) },
entry: { 'wp-notify': path.resolve( process.cwd(), `src/wp-notify.js` ) },
};