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

TypeScript Support #90

Merged
merged 21 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.DS_Store
node_modules
configs/tsconfig/tsconfig.json
configs/tsconfig/tsconfig-*.json
!configs/tsconfig/tsconfig-source.json
example-site/**/dist
example-site/**/inc/asset-settings.php
11 changes: 7 additions & 4 deletions configs/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ module.exports = (projectConfig) => {
es2021: true,
node: true,
},
extends: ['airbnb', 'prettier'],
extends: ['airbnb', 'prettier', 'plugin:@typescript-eslint/recommended'],
parser: '@babel/eslint-parser',
parserOptions: {
requireConfigFile: false,
babelOptions: {
...babelConfig,
},
},
plugins: ['@babel', 'react', 'prettier', 'jsdoc'],
plugins: ['@babel', 'react', 'prettier', 'jsdoc', 'import', '@typescript-eslint/eslint-plugin'],
settings: {
'import/resolver': eslintResolver(projectConfig.paths.src),
'import/resolver': eslintResolver(projectConfig.paths),
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
},
rules: {
complexity: ['error', 10],
Expand All @@ -37,7 +40,7 @@ module.exports = (projectConfig) => {
],
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.ts', '.tsx'] }],
'react/react-in-jsx-scope': 0,
'react/prop-types': 0,
'react/forbid-prop-types': 0,
Expand Down
29 changes: 29 additions & 0 deletions configs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": false,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"noUncheckedIndexedAccess": true,
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
"typeRoots": [
"./types"
]
},
"include": [
"typescript/images.d.ts"
],
"exclude": ["node_modules"]
}
Empty file added configs/typescript/dummy.ts
Empty file.
13 changes: 13 additions & 0 deletions configs/typescript/images.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare module '*.png';
declare module '*.jpeg';
declare module '*.jpg';

declare module '*.svg' {
const content: React.FunctionComponent<React.SVGAttributes<SVGElement>>;
export default content;
}

declare module '*.svg?url' {
const content: string;
export default content;
}

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

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "test-client-plugin"
"name": "@namespace/test-client-plugin"
}
Loading