Skip to content

Commit

Permalink
feat: Add React with Typescript target
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidmt committed Jan 20, 2021
1 parent 476192c commit fb2d88e
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 24 deletions.
8 changes: 0 additions & 8 deletions rules/import-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

module.exports = {
rules: {
/*
* A list of file extensions that will be parsed as modules and
* inspected for exports.
*/
"import/extensions": ["error", "always", { js: "never", ts: "never" }],

/*
* TypeScript compilation already ensures that named imports exist in the
* referenced module
Expand All @@ -16,8 +10,6 @@ module.exports = {
},

settings: {
"import/extensions": [".ts", ".tsx", ".d.ts", ".js", ".jsx"],

"import/external-module-folders": ["node_modules", "node_modules/@types"],

"import/parsers": {
Expand Down
16 changes: 0 additions & 16 deletions rules/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ module.exports = {
},
],

// Restrict file extensions that may contain JSX
"react/jsx-filename-extension": "error",

// Validate JSX maximum depth
"react/jsx-max-depth": "off",

Expand Down Expand Up @@ -335,18 +332,5 @@ module.exports = {

// Prevent usage of button elements without an explicit type attribute
"react/button-has-type": "error",

/*
* A list of file extensions that will be parsed as modules and
* inspected for exports.
*/
"import/extensions": [
"error",
"always",
{
js: "never",
jsx: "never",
},
],
},
}
2 changes: 2 additions & 0 deletions targets/node-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ module.exports = {

plugins: ["json", "no-inferred-method-name"],

ignorePatterns: ["dist/*.js", "*.d.ts"],

rules: {
"@typescript-eslint/no-var-requires": "off",

Expand Down
133 changes: 133 additions & 0 deletions targets/react-ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/* eslint-env node */

module.exports = {
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},

env: {
browser: true,
es6: true,
node: false,
},

extends: [
...[
"../rules/best.practices",
"../rules/comments",
"../rules/errors",
"../rules/es6",
"../rules/html",
"../rules/import",
"../rules/import-ts",
"../rules/jsdoc",
"../rules/promise",
"../rules/react",
"../rules/style",
"../rules/unicorn",
"../rules/variables",
"../rules/prettier",
].map(require.resolve),

// Disable ESLint rules from @typescript-eslint/eslint-plugin that
// conflict with prettier
"prettier/@typescript-eslint",

"plugin:@typescript-eslint/recommended",
],

plugins: ["json", "no-inferred-method-name"],

ignorePatterns: ["dist/*.js", "*.d.ts"],

rules: {
"react/prop-types": "off",

// Ensure JSDoc comments are valid
"valid-jsdoc": [
"error",
{
requireReturn: false,
requireReturnDescription: false,
requireReturnType: true,
},
],

"@typescript-eslint/no-var-requires": "off",

// Disable, it gives false positives. let eslint/no-unused-vars
"@typescript-eslint/no-unused-vars": "off",

// Restrict file extensions that may contain JSX
"react/jsx-filename-extension": [
"error",
{ extensions: [".js", ".jsx", ".tsx", ".ts"] },
],

// Let Typescript handle it
"@typescript-eslint/no-use-before-define": "error",
"no-use-before-define": "off",

/*
* A list of file extensions that will be parsed as modules and
* inspected for exports.
*/
"import/extensions": [
"error",
"always",
{
js: "never",
ts: "never",
jsx: "never",
tsx: "never",
},
],

"no-unused-vars": [
"error",
{
args: "after-used",
varsIgnorePattern: "debug",
},
],
},

settings: {
react: {
version: "detect",
},

/*
* A list of regex strings that, if matched by a path, will not report
* the matching module if no exports are found.
*/
"import/ignore": [".(sass|scss|less|css)$"],

/*
* A list of file extensions that will be parsed as modules and
* inspected for exports.
*/
"import/extensions": [
"error",
"always",
{
js: "never",
ts: "never",
jsx: "never",
tsx: "never",
},
],

"no-unused-vars": [
"error",
{
args: "after-used",
varsIgnorePattern: "debug",
},
],
},
}
30 changes: 30 additions & 0 deletions targets/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,37 @@ module.exports = {

plugins: ["json", "no-inferred-method-name"],

rules: {
"no-unused-vars": [
"error",
{
args: "after-used",
varsIgnorePattern: "debug",
},
],

/*
* A list of file extensions that will be parsed as modules and
* inspected for exports.
*/
"import/extensions": [
"error",
"always",
{
js: "never",
jsx: "never",
},
],

// Restrict file extensions that may contain JSX
"react/jsx-filename-extension": ["error", { extensions: [".js", ".jsx"] }],
},

settings: {
react: {
version: "detect",
},

/*
* A list of regex strings that, if matched by a path, will not report
* the matching module if no exports are found.
Expand Down

0 comments on commit fb2d88e

Please sign in to comment.