Skip to content

Commit

Permalink
Merge pull request #90 from bigbite/feature/typescript-support
Browse files Browse the repository at this point in the history
TypeScript Support
  • Loading branch information
ampersarnie authored Jul 30, 2023
2 parents 6bdb058 + 461b3a8 commit 93ac645
Show file tree
Hide file tree
Showing 21 changed files with 2,356 additions and 370 deletions.
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

0 comments on commit 93ac645

Please sign in to comment.