-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: lint command in JS adapters to use current directory, correct li…
…nt errors in templates (#947)
- Loading branch information
Showing
53 changed files
with
453 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Fixed `lint` command for JS adapters | ||
|
||
The `lint` command for JS adapters was incorrectly defined and did nothing. To fix this, open `package.json` and look for the `"lint"` script. | ||
|
||
Apply this change | ||
|
||
```diff | ||
- "lint": "eslint", | ||
+ "lint": "eslint .", | ||
``` | ||
|
||
or this change | ||
|
||
```diff | ||
- "lint": "eslint --ext .js,.jsx", | ||
+ "lint": "eslint --ext .js,.jsx .", | ||
``` | ||
|
||
If the script is defined differently, there should be no need to change it. | ||
|
||
**Note:** You will have to fix a couple of linting errors after doing this. Some can be automatically fixed, some require configuration changes that are too complex to describe here. If you are unable to fix some, try re-creating your adapter with the newest creator version and then copy your code over. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { TemplateFunction } from "../../src/lib/createAdapter"; | ||
|
||
const templateFunction: TemplateFunction = answers => { | ||
|
||
const useTypeScript = answers.language === "TypeScript"; | ||
const useReact = | ||
answers.adminUi === "react" || answers.tabReact === "yes"; | ||
if (useTypeScript || !useReact) return; | ||
|
||
const template = ` | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"project": "./tsconfig.json" | ||
}, | ||
"rules": { | ||
"react/prop-types": "off" | ||
} | ||
} | ||
`; | ||
return template.trim(); | ||
}; | ||
|
||
templateFunction.customPath = "admin/.eslintrc.json"; | ||
export = templateFunction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import * as JSON5 from "json5"; | ||
import type { TemplateFunction } from "../../src/lib/createAdapter"; | ||
|
||
const templateFunction: TemplateFunction = answers => { | ||
|
||
// This version is intended to make ESLint happy with the JS tests in TS adapters | ||
if (answers.language !== "TypeScript") return; | ||
const useESLint = answers.tools && answers.tools.indexOf("ESLint") > -1; | ||
if (!useESLint) return; | ||
|
||
const template = ` | ||
{ | ||
"root": true, | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended" | ||
], | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
${answers.indentation === "Tab" ? `"tab"` : "4"}, | ||
{ | ||
"SwitchCase": 1 | ||
} | ||
], | ||
"no-console": "off", | ||
"no-unused-vars": [ | ||
"error", | ||
{ | ||
"ignoreRestSiblings": true, | ||
"argsIgnorePattern": "^_", | ||
} | ||
], | ||
"no-var": "error", | ||
"no-trailing-spaces": "error", | ||
"prefer-const": "error", | ||
"quotes": [ | ||
"error", | ||
"${typeof answers.quotes === "string" ? answers.quotes : "double"}", | ||
{ | ||
"avoidEscape": true, | ||
"allowTemplateLiterals": true | ||
} | ||
], | ||
"semi": [ | ||
"error", | ||
"always" | ||
] | ||
} | ||
} | ||
`; | ||
return JSON.stringify(JSON5.parse(template), null, 4); | ||
}; | ||
|
||
templateFunction.customPath = "test/.eslintrc.json"; | ||
export = templateFunction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { TemplateFunction } from "../../src/lib/createAdapter"; | ||
|
||
const templateFunction: TemplateFunction = answers => { | ||
|
||
const isWidget = answers.features.indexOf("vis") > -1; | ||
if (!isWidget) return; | ||
|
||
const template = ` | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": false | ||
}, | ||
"rules": { | ||
// Visualizations may run in very old browsers without \`let\` and \`const\` | ||
"no-var": "off", | ||
// The example code does not use some parameters. If unused variables should be | ||
// an error, delete the following rule | ||
"no-unused-vars": [ | ||
"warn", | ||
{ | ||
"ignoreRestSiblings": true, | ||
"argsIgnorePattern": "^_" | ||
} | ||
] | ||
} | ||
} | ||
`; | ||
return template.trim(); | ||
}; | ||
|
||
templateFunction.customPath = "widgets/.eslintrc.json"; | ||
export = templateFunction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...nes/adapter_JS_ES6Class_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/admin/words.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.