├── .gitignore ├── .eslintrc.js ├── prettier.config.js ├── .editorconfig ├── README.md ├── index.js ├── package.json └── .circleci └── config.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = Object.assign({}, require('./'), { 2 | env: { 3 | es6: true, 4 | node: true 5 | } 6 | }); 7 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | singleQuote: true, 3 | tabWidth: 4, 4 | trailingComma: 'none' 5 | }; 6 | 7 | module.exports = config; 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [{package.json,*.yml}] 12 | indent_size = 2 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento ESLint Configuration 2 | 3 | Shareable `ESLint` configuration used by all Magento PWA Studio projects. 4 | 5 | ## Goals 6 | 7 | * Lint for possible errors and mistakes. No rules for stylistic preferences will be accepted 8 | 9 | ## Usage 10 | 11 | ```sh 12 | npm install @magento/eslint-config 13 | ``` 14 | 15 | ```js 16 | // in your ESLint configuration 17 | extends: ['@magento'] 18 | ``` 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | env: { 3 | es6: true 4 | }, 5 | plugins: ['jsx-a11y', 'package-json', 'react', 'react-hooks'], 6 | extends: [ 7 | 'eslint:recommended', 8 | 'prettier', 9 | 'plugin:jsx-a11y/recommended', 10 | 'plugin:package-json/recommended' 11 | ], 12 | rules: { 13 | 'prefer-const': 'error', 14 | 'no-console': 'off', 15 | 'no-unused-vars': 'error', 16 | 'react/jsx-uses-vars': 'error', 17 | 'react/jsx-uses-react': 'error', 18 | 'react-hooks/exhaustive-deps': 'error', 19 | 'react-hooks/rules-of-hooks': 'error', 20 | 'no-duplicate-imports': 'error', 21 | 'one-var': ['error', 'never'] 22 | } 23 | }; 24 | 25 | module.exports = config; 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@magento/eslint-config", 3 | "version": "1.5.2", 4 | "description": "Shared ESLint configuration for Magento PWA-related projects", 5 | "main": "index.js", 6 | "files": [ 7 | "index.js" 8 | ], 9 | "scripts": { 10 | "lint": "eslint --ext .js --ext .json .", 11 | "prettier": "prettier --write '*.js'", 12 | "prettier:check": "prettier-check '*.js'", 13 | "test": "npm run -s prettier:check && npm run -d lint" 14 | }, 15 | "keywords": [ 16 | "magento", 17 | "eslint" 18 | ], 19 | "author": "Magento Commerce", 20 | "license": "(OSL-3.0 OR AFL-3.0)", 21 | "devDependencies": { 22 | "eslint": "^5.16.0", 23 | "eslint-config-prettier": "^6.0.0", 24 | "eslint-plugin-jsx-a11y": "^6.0.3", 25 | "eslint-plugin-package-json": "^0.1.4", 26 | "eslint-plugin-react": "^7.9.1", 27 | "eslint-plugin-react-hooks": "^1.6.0", 28 | "prettier": "^1.9.2", 29 | "prettier-check": "^2.0.0" 30 | }, 31 | "peerDependencies": { 32 | "eslint-config-prettier": "^6.0.0", 33 | "eslint-plugin-jsx-a11y": "^6.0.3", 34 | "eslint-plugin-package-json": "^0.1.4", 35 | "eslint-plugin-react": "^7.5.1", 36 | "eslint-plugin-react-hooks": "^1.6.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | # This key means nothing to CircleCI; it's just a place to keep anchored 4 | # configuration nodes for reuse. 5 | common_settings: 6 | working_directory: &workdir ~/project 7 | cache_key: &cachekey 'v1-npm-cache-{{ .Branch }}' 8 | docker: &docker_setup 9 | - image: 'circleci/node:8.11.2' 10 | 11 | install_latest_npm: &install_latest_npm 12 | name: Ensure NPM is up to date 13 | command: sudo npm install -g npm@latest 14 | jobs: 15 | test: 16 | docker: *docker_setup 17 | working_directory: *workdir 18 | steps: 19 | - checkout 20 | - restore_cache: 21 | keys: 22 | - *cachekey 23 | - v1-npm-cache- 24 | - run: *install_latest_npm 25 | - run: npm ci 26 | - run: npm test 27 | - save_cache: 28 | paths: 29 | - ~/.ssh 30 | - ~/.npm 31 | - /root/.npm 32 | key: *cachekey 33 | - persist_to_workspace: 34 | root: *workdir 35 | paths: 36 | - . 37 | deploy: 38 | docker: *docker_setup 39 | working_directory: *workdir 40 | steps: 41 | - attach_workspace: 42 | at: *workdir 43 | - run: *install_latest_npm 44 | - run: 45 | name: Authenticate with registry 46 | command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc 47 | - run: 48 | name: Publish package 49 | command: npm publish --access=public 50 | 51 | workflows: 52 | version: 2 53 | test-and-deploy: 54 | jobs: 55 | - test: 56 | filters: 57 | tags: 58 | only: /.*/ 59 | - deploy: 60 | requires: 61 | - test 62 | filters: 63 | tags: 64 | only: /^v.*/ 65 | branches: 66 | ignore: /.*/ 67 | --------------------------------------------------------------------------------