diff --git a/packages/tasks/common/build.js b/packages/tasks/common/build.js index ccf6728b7..57fc4a9dd 100644 --- a/packages/tasks/common/build.js +++ b/packages/tasks/common/build.js @@ -25,7 +25,8 @@ module.exports = function build(config) { // Use `.babelrc.template` as name to not trigger babel // when requiring the file `.template.js` in end-to-end tests // and rename it `.babelrc` afterwards - [/\.babelrc.template$/, '.babelrc'], + ['.babelrc.template', '.babelrc'], + ['.eslintrc.js.hbs', '.eslintrc.js'], ]) ) .use(inPlace()) diff --git a/scripts/__snapshots__/e2e-templates.test.js.snap b/scripts/__snapshots__/e2e-templates.test.js.snap index bb5d8bd76..e5847327d 100644 --- a/scripts/__snapshots__/e2e-templates.test.js.snap +++ b/scripts/__snapshots__/e2e-templates.test.js.snap @@ -945,6 +945,30 @@ Array [ ] `; +exports[`Templates InstantSearch.js File content: .editorconfig 1`] = ` +"root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true" +`; + +exports[`Templates InstantSearch.js File content: .eslintignore 1`] = ` +"/node_modules +/dist +/.cache" +`; + +exports[`Templates InstantSearch.js File content: .eslintrc.js 1`] = ` +"module.exports = { + extends: 'algolia', +};" +`; + exports[`Templates InstantSearch.js File content: .gitignore 1`] = ` "# See https://help.github.com/ignore-files/ for more about ignoring files. @@ -970,6 +994,14 @@ yarn-debug.log* yarn-error.log*" `; +exports[`Templates InstantSearch.js File content: .prettierrc 1`] = ` +"{ + \\"singleQuote\\": true, + \\"proseWrap\\": \\"never\\", + \\"trailingComma\\": \\"es5\\" +}" +`; + exports[`Templates InstantSearch.js File content: README.md 1`] = ` "# instantsearch.js-app @@ -1073,10 +1105,19 @@ exports[`Templates InstantSearch.js File content: package.json 1`] = ` \\"private\\": true, \\"scripts\\": { \\"start\\": \\"parcel index.html --port 3000\\", - \\"build\\": \\"parcel build index.html\\" + \\"build\\": \\"parcel build index.html\\", + \\"lint\\": \\"eslint .\\", + \\"lint:fix\\": \\"npm run lint -- --fix\\" }, \\"devDependencies\\": { - \\"parcel-bundler\\": \\"^1.8.1\\" + \\"babel-eslint\\": \\"^8.2.3\\", + \\"eslint\\": \\"^4.19.1\\", + \\"eslint-config-algolia\\": \\"^13.1.0\\", + \\"eslint-config-prettier\\": \\"^2.9.0\\", + \\"eslint-plugin-import\\": \\"^2.12.0\\", + \\"eslint-plugin-prettier\\": \\"^2.6.0\\", + \\"parcel-bundler\\": \\"^1.8.1\\", + \\"prettier\\": \\"^1.13.4\\" } }" `; @@ -1202,7 +1243,6 @@ search.addWidget( }) ); - search.addWidget( instantsearch.widgets.pagination({ container: '#pagination', @@ -1227,7 +1267,11 @@ body { exports[`Templates InstantSearch.js Folder structure: contains the right files 1`] = ` Array [ + ".editorconfig", + ".eslintignore", + ".eslintrc.js", ".gitignore", + ".prettierrc", "README.md", "favicon.png", "index.html", @@ -1239,6 +1283,24 @@ Array [ ] `; +exports[`Templates React InstantSearch File content: .editorconfig 1`] = ` +"root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true" +`; + +exports[`Templates React InstantSearch File content: .eslintrc.js 1`] = ` +"module.exports = { + extends: 'algolia/react', +};" +`; + exports[`Templates React InstantSearch File content: .gitignore 1`] = ` "# See https://help.github.com/ignore-files/ for more about ignoring files. @@ -1263,6 +1325,14 @@ yarn-debug.log* yarn-error.log*" `; +exports[`Templates React InstantSearch File content: .prettierrc 1`] = ` +"{ + \\"singleQuote\\": true, + \\"proseWrap\\": \\"never\\", + \\"trailingComma\\": \\"es5\\" +}" +`; + exports[`Templates React InstantSearch File content: README.md 1`] = ` "# react-instantsearch-app @@ -1292,7 +1362,9 @@ exports[`Templates React InstantSearch File content: package.json 1`] = ` \\"private\\": true, \\"scripts\\": { \\"start\\": \\"react-scripts start\\", - \\"build\\": \\"react-scripts build\\" + \\"build\\": \\"react-scripts build\\", + \\"lint\\": \\"eslint .\\", + \\"lint:fix\\": \\"npm run lint -- --fix\\" }, \\"dependencies\\": { \\"react\\": \\"^16.3.2\\", @@ -1301,6 +1373,13 @@ exports[`Templates React InstantSearch File content: package.json 1`] = ` \\"react-scripts\\": \\"1.1.4\\" }, \\"devDependencies\\": { + \\"eslint\\": \\"^4.19.1\\", + \\"eslint-config-algolia\\": \\"^13.1.0\\", + \\"eslint-config-prettier\\": \\"^2.9.0\\", + \\"eslint-plugin-import\\": \\"^2.12.0\\", + \\"eslint-plugin-prettier\\": \\"^2.6.0\\", + \\"eslint-plugin-react\\": \\"^7.9.1\\", + \\"prettier\\": \\"^1.13.4\\", \\"prop-types\\": \\"^15.6.1\\" } }" @@ -1515,7 +1594,10 @@ ReactDOM.render(, document.getElementById('root'));" exports[`Templates React InstantSearch Folder structure: contains the right files 1`] = ` Array [ + ".editorconfig", + ".eslintrc.js", ".gitignore", + ".prettierrc", "README.md", "package.json", "public/favicon.png", @@ -1537,6 +1619,27 @@ exports[`Templates Vue InstantSearch File content: .babelrc 1`] = ` }" `; +exports[`Templates Vue InstantSearch File content: .editorconfig 1`] = ` +"root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true" +`; + +exports[`Templates Vue InstantSearch File content: .eslintrc.js 1`] = ` +"module.exports = { + extends: 'algolia/vue', + rules: { + 'import/no-commonjs': 'off', + }, +};" +`; + exports[`Templates Vue InstantSearch File content: .gitignore 1`] = ` "node_modules/ npm-debug.log @@ -1626,7 +1729,9 @@ exports[`Templates Vue InstantSearch File content: package.json 1`] = ` \\"private\\": true, \\"scripts\\": { \\"start\\": \\"cross-env NODE_ENV=development webpack-dev-server --port 3000 --hot\\", - \\"build\\": \\"cross-env NODE_ENV=production webpack --progress --hide-modules\\" + \\"build\\": \\"cross-env NODE_ENV=production webpack --progress --hide-modules\\", + \\"lint\\": \\"eslint --ext .js,.vue .\\", + \\"lint:fix\\": \\"npm run lint -- --fix\\" }, \\"dependencies\\": { \\"vue\\": \\"^2.5.16\\", @@ -1634,12 +1739,20 @@ exports[`Templates Vue InstantSearch File content: package.json 1`] = ` }, \\"devDependencies\\": { \\"babel-core\\": \\"6.26.0\\", + \\"babel-eslint\\": \\"^8.2.3\\", \\"babel-loader\\": \\"7.1.4\\", \\"babel-preset-env\\": \\"1.6.1\\", \\"babel-preset-stage-3\\": \\"6.24.1\\", \\"cross-env\\": \\"5.1.4\\", \\"css-loader\\": \\"0.28.11\\", + \\"eslint\\": \\"^4.19.1\\", + \\"eslint-config-algolia\\": \\"^13.1.0\\", + \\"eslint-config-prettier\\": \\"^2.9.0\\", + \\"eslint-plugin-html\\": \\"^4.0.3\\", + \\"eslint-plugin-import\\": \\"^2.12.0\\", + \\"eslint-plugin-prettier\\": \\"^2.6.0\\", \\"file-loader\\": \\"1.1.11\\", + \\"prettier\\": \\"^1.13.4\\", \\"vue-loader\\": \\"14.2.2\\", \\"vue-template-compiler\\": \\"2.5.16\\", \\"webpack\\": \\"3.11.0\\", @@ -1888,6 +2001,8 @@ if (process.env.NODE_ENV === 'production') { exports[`Templates Vue InstantSearch Folder structure: contains the right files 1`] = ` Array [ ".babelrc", + ".editorconfig", + ".eslintrc.js", ".gitignore", "README.md", "favicon.png", diff --git a/templates/InstantSearch.js/.editorconfig b/templates/InstantSearch.js/.editorconfig new file mode 100644 index 000000000..9d08a1a82 --- /dev/null +++ b/templates/InstantSearch.js/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/templates/InstantSearch.js/.eslintignore b/templates/InstantSearch.js/.eslintignore new file mode 100644 index 000000000..9178ddcd8 --- /dev/null +++ b/templates/InstantSearch.js/.eslintignore @@ -0,0 +1,3 @@ +/node_modules +/dist +/.cache diff --git a/templates/InstantSearch.js/.eslintrc.js b/templates/InstantSearch.js/.eslintrc.js new file mode 100644 index 000000000..67b68ebe5 --- /dev/null +++ b/templates/InstantSearch.js/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: 'algolia', +}; diff --git a/templates/InstantSearch.js/.prettierrc b/templates/InstantSearch.js/.prettierrc new file mode 100644 index 000000000..833f03b62 --- /dev/null +++ b/templates/InstantSearch.js/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "proseWrap": "never", + "trailingComma": "es5" +} diff --git a/templates/InstantSearch.js/package.json b/templates/InstantSearch.js/package.json index 58b75aec7..65941ecda 100644 --- a/templates/InstantSearch.js/package.json +++ b/templates/InstantSearch.js/package.json @@ -4,9 +4,18 @@ "private": true, "scripts": { "start": "parcel index.html --port 3000", - "build": "parcel build index.html" + "build": "parcel build index.html", + "lint": "eslint .", + "lint:fix": "npm run lint -- --fix" }, "devDependencies": { - "parcel-bundler": "^1.8.1" + "babel-eslint": "^8.2.3", + "eslint": "^4.19.1", + "eslint-config-algolia": "^13.1.0", + "eslint-config-prettier": "^2.9.0", + "eslint-plugin-import": "^2.12.0", + "eslint-plugin-prettier": "^2.6.0", + "parcel-bundler": "^1.8.1", + "prettier": "^1.13.4" } } diff --git a/templates/InstantSearch.js/src/app.js.hbs b/templates/InstantSearch.js/src/app.js.hbs index 52a3702f4..13c7c4533 100644 --- a/templates/InstantSearch.js/src/app.js.hbs +++ b/templates/InstantSearch.js/src/app.js.hbs @@ -39,7 +39,6 @@ search.addWidget( ); {{/each}} - search.addWidget( instantsearch.widgets.pagination({ container: '#pagination', diff --git a/templates/React InstantSearch/.editorconfig b/templates/React InstantSearch/.editorconfig new file mode 100644 index 000000000..9d08a1a82 --- /dev/null +++ b/templates/React InstantSearch/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/templates/React InstantSearch/.eslintrc.js b/templates/React InstantSearch/.eslintrc.js new file mode 100644 index 000000000..5b815c0d4 --- /dev/null +++ b/templates/React InstantSearch/.eslintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: 'algolia/react', +}; diff --git a/templates/React InstantSearch/.prettierrc b/templates/React InstantSearch/.prettierrc new file mode 100644 index 000000000..833f03b62 --- /dev/null +++ b/templates/React InstantSearch/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "proseWrap": "never", + "trailingComma": "es5" +} diff --git a/templates/React InstantSearch/package.json b/templates/React InstantSearch/package.json index 78eb397e0..7e977757d 100644 --- a/templates/React InstantSearch/package.json +++ b/templates/React InstantSearch/package.json @@ -4,7 +4,9 @@ "private": true, "scripts": { "start": "react-scripts start", - "build": "react-scripts build" + "build": "react-scripts build", + "lint": "eslint .", + "lint:fix": "npm run lint -- --fix" }, "dependencies": { "react": "^16.3.2", @@ -13,6 +15,13 @@ "react-scripts": "1.1.4" }, "devDependencies": { + "eslint": "^4.19.1", + "eslint-config-algolia": "^13.1.0", + "eslint-config-prettier": "^2.9.0", + "eslint-plugin-import": "^2.12.0", + "eslint-plugin-prettier": "^2.6.0", + "eslint-plugin-react": "^7.9.1", + "prettier": "^1.13.4", "prop-types": "^15.6.1" } } diff --git a/templates/Vue InstantSearch/.editorconfig b/templates/Vue InstantSearch/.editorconfig new file mode 100644 index 000000000..9d08a1a82 --- /dev/null +++ b/templates/Vue InstantSearch/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/templates/Vue InstantSearch/.eslintrc.js b/templates/Vue InstantSearch/.eslintrc.js new file mode 100644 index 000000000..1e03da618 --- /dev/null +++ b/templates/Vue InstantSearch/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + extends: 'algolia/vue', + rules: { + 'import/no-commonjs': 'off', + }, +}; diff --git a/templates/Vue InstantSearch/package.json b/templates/Vue InstantSearch/package.json index 978ff378b..edca7727f 100644 --- a/templates/Vue InstantSearch/package.json +++ b/templates/Vue InstantSearch/package.json @@ -4,7 +4,9 @@ "private": true, "scripts": { "start": "cross-env NODE_ENV=development webpack-dev-server --port 3000 --hot", - "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" + "build": "cross-env NODE_ENV=production webpack --progress --hide-modules", + "lint": "eslint --ext .js,.vue .", + "lint:fix": "npm run lint -- --fix" }, "dependencies": { "vue": "^2.5.16", @@ -12,12 +14,20 @@ }, "devDependencies": { "babel-core": "6.26.0", + "babel-eslint": "^8.2.3", "babel-loader": "7.1.4", "babel-preset-env": "1.6.1", "babel-preset-stage-3": "6.24.1", "cross-env": "5.1.4", "css-loader": "0.28.11", + "eslint": "^4.19.1", + "eslint-config-algolia": "^13.1.0", + "eslint-config-prettier": "^2.9.0", + "eslint-plugin-html": "^4.0.3", + "eslint-plugin-import": "^2.12.0", + "eslint-plugin-prettier": "^2.6.0", "file-loader": "1.1.11", + "prettier": "^1.13.4", "vue-loader": "14.2.2", "vue-template-compiler": "2.5.16", "webpack": "3.11.0",