Skip to content

Commit

Permalink
build: configure eslint for JSDoc types (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhooks committed Apr 7, 2023
1 parent 29d9113 commit 1c2f00e
Show file tree
Hide file tree
Showing 9 changed files with 223 additions and 16 deletions.
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' ],
};
};
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"
]
}
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` ) },
};

0 comments on commit 1c2f00e

Please sign in to comment.