├── .npmrc ├── .eslintignore ├── .gitignore ├── packages ├── eslint-config-base │ ├── index.js │ ├── cjs │ │ ├── index.js │ │ ├── es2015.js │ │ ├── es2016.js │ │ ├── es2017.js │ │ ├── es2018.js │ │ ├── es2019.js │ │ └── es2020.js │ ├── esm │ │ ├── index.js │ │ ├── es2015.js │ │ ├── es2016.js │ │ ├── es2017.js │ │ ├── es2018.js │ │ ├── es2019.js │ │ └── es2020.js │ ├── test │ │ ├── samples │ │ │ ├── es2015-cjs │ │ │ │ ├── .eslintrc.json │ │ │ │ ├── contrived.bad-syntax.js │ │ │ │ ├── commitlint.config.js │ │ │ │ ├── contrived.bad.js │ │ │ │ └── contrived.good.js │ │ │ ├── es2015-esm │ │ │ │ ├── .eslintrc.json │ │ │ │ ├── commitlint.config.js │ │ │ │ ├── contrived.good.js │ │ │ │ └── contrived.bad.js │ │ │ ├── es2015 │ │ │ │ ├── commitlint.config.js │ │ │ │ ├── .eslintrc.json │ │ │ │ └── contrived.good.js │ │ │ ├── es2016 │ │ │ │ ├── contrived.good.js │ │ │ │ ├── .eslintrc.json │ │ │ │ └── contrived.bad.js │ │ │ ├── es2017 │ │ │ │ ├── .eslintrc.json │ │ │ │ └── contrived.good.js │ │ │ ├── es2018 │ │ │ │ ├── .eslintrc.json │ │ │ │ └── contrived.good.js │ │ │ └── es2019 │ │ │ │ ├── .eslintrc.json │ │ │ │ └── contrived.good.js │ │ └── rules │ │ │ ├── es6-esm.js │ │ │ ├── strict.js │ │ │ ├── jsdoc.js │ │ │ ├── variables-no-unused.js │ │ │ ├── node.js │ │ │ ├── .eslintrc.json │ │ │ └── variables.js │ ├── lib │ │ ├── test-patterns.js │ │ ├── rules │ │ │ ├── strict.js │ │ │ ├── node.js │ │ │ ├── import.js │ │ │ ├── variables.js │ │ │ ├── jsdoc.js │ │ │ ├── errors.js │ │ │ ├── es6.js │ │ │ └── best-practices.js │ │ └── modules │ │ │ ├── cjs.js │ │ │ └── esm.js │ ├── es2019.js │ ├── es2017.js │ ├── es2020.js │ ├── es2016.js │ ├── es2018.js │ ├── es2015.js │ ├── package.json │ ├── README.md │ └── CHANGELOG.md ├── eslint-config-react-native-a11y │ ├── index.js │ ├── ios.js │ ├── android.js │ ├── rn-060 │ │ ├── index.js │ │ ├── ios.js │ │ └── android.js │ ├── rn-061 │ │ ├── index.js │ │ ├── ios.js │ │ └── android.js │ ├── rn-062 │ │ ├── index.js │ │ ├── ios.js │ │ └── android.js │ ├── test │ │ ├── .babelrc.json │ │ ├── samples │ │ │ └── my-component │ │ │ │ └── MyComponent.test.js │ │ └── .eslintrc.json │ ├── rn-059 │ │ ├── ios.js │ │ ├── android.js │ │ ├── index.js │ │ └── base-config.js │ ├── lib │ │ └── rules │ │ │ └── platforms │ │ │ ├── rn-061 │ │ │ └── any.js │ │ │ ├── rn-062 │ │ │ └── any.js │ │ │ ├── rn-060 │ │ │ └── any.js │ │ │ └── rn-059 │ │ │ ├── ios.js │ │ │ ├── android.js │ │ │ └── any.js │ ├── package.json │ ├── CHANGELOG.md │ └── README.md ├── eslint-config-react-native │ ├── test │ │ ├── rules │ │ │ ├── split-platform-components │ │ │ │ ├── no-unresolved │ │ │ │ │ ├── ios-only │ │ │ │ │ │ ├── MyComponent.ios.js │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── android-only │ │ │ │ │ │ ├── MyComponent.android.js │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── both-platforms │ │ │ │ │ │ ├── MyComponent.ios.js │ │ │ │ │ │ ├── MyComponent.android.js │ │ │ │ │ │ └── index.js │ │ │ │ │ └── no-platform │ │ │ │ │ │ └── index.js │ │ │ │ ├── MyComponent.ios.js │ │ │ │ ├── MyIOSComponent.js │ │ │ │ ├── MyComponent.android.js │ │ │ │ ├── MyIOSComponent.android.js │ │ │ │ ├── MyAndroidComponent.js │ │ │ │ ├── MyAndroidComponent.ios.js │ │ │ │ └── MyComponent.js │ │ │ ├── no-unused-styles │ │ │ │ ├── imported-styles │ │ │ │ │ ├── function-component │ │ │ │ │ │ ├── MyComponent.js │ │ │ │ │ │ └── styles.js │ │ │ │ │ └── class-component │ │ │ │ │ │ ├── MyComponent.js │ │ │ │ │ │ └── styles.js │ │ │ │ └── same-file-styles │ │ │ │ │ ├── function-component.js │ │ │ │ │ ├── function-component-fragment.js │ │ │ │ │ ├── class-component.js │ │ │ │ │ └── class-component-fragment.js │ │ │ ├── env.js │ │ │ ├── no-inline-styles.js │ │ │ ├── no-raw-text.js │ │ │ ├── no-single-element-style-arrays.js │ │ │ ├── sort-styles.js │ │ │ └── no-color-literals.js │ │ ├── .babelrc.json │ │ ├── samples │ │ │ └── my-component │ │ │ │ └── MyComponent.test.js │ │ └── .eslintrc.json │ ├── lib │ │ ├── rules │ │ │ ├── platform-specific-components.js │ │ │ └── react-native.js │ │ └── index.js │ ├── package.json │ ├── README.md │ └── CHANGELOG.md ├── eslint-config-babel │ ├── test │ │ ├── .babelrc.json │ │ ├── .eslintrc.json │ │ └── samples │ │ │ └── my-class │ │ │ └── MyClass.js │ ├── lib │ │ └── index.js │ ├── package.json │ ├── README.md │ └── CHANGELOG.md ├── eslint-config-jest │ ├── test │ │ ├── samples │ │ │ ├── project-esm │ │ │ │ ├── __mocks__ │ │ │ │ │ └── other-sample-mock.js │ │ │ │ ├── jest.setup.js │ │ │ │ ├── test.js │ │ │ │ ├── test.ts │ │ │ │ ├── test │ │ │ │ │ ├── test.js │ │ │ │ │ ├── non-test-file.js │ │ │ │ │ ├── test-file.test.js │ │ │ │ │ └── non-test-file.spec.js │ │ │ │ ├── tests │ │ │ │ │ ├── test.js │ │ │ │ │ ├── non-test-file.js │ │ │ │ │ ├── test-file.test.js │ │ │ │ │ └── non-test-file.spec.js │ │ │ │ ├── __tests__ │ │ │ │ │ ├── test.js │ │ │ │ │ ├── non-test-file.js │ │ │ │ │ ├── test-file.test.js │ │ │ │ │ └── non-test-file.spec.js │ │ │ │ ├── non-test-file.js │ │ │ │ ├── test-file.test.js │ │ │ │ ├── non-test-file.spec.js │ │ │ │ └── .eslintrc.json │ │ │ └── project-cjs │ │ │ │ ├── __mocks__ │ │ │ │ └── sample-mock.js │ │ │ │ ├── jest.setup.js │ │ │ │ ├── test.js │ │ │ │ ├── test.ts │ │ │ │ ├── test │ │ │ │ ├── test.js │ │ │ │ ├── non-test-file.js │ │ │ │ ├── test-file.test.js │ │ │ │ └── non-test-file.spec.js │ │ │ │ ├── __tests__ │ │ │ │ ├── test.js │ │ │ │ ├── non-test-file.js │ │ │ │ ├── test-file.test.js │ │ │ │ └── non-test-file.spec.js │ │ │ │ ├── non-test-file.js │ │ │ │ ├── test-file.test.js │ │ │ │ ├── tests │ │ │ │ ├── test.js │ │ │ │ ├── non-test-file.js │ │ │ │ ├── non-test-file.spec.js │ │ │ │ └── test-file.test.js │ │ │ │ ├── non-test-file.spec.js │ │ │ │ └── .eslintrc.json │ │ └── rules │ │ │ ├── .eslintrc.json │ │ │ └── jest.test.js │ ├── lib │ │ ├── index.js │ │ └── rules │ │ │ └── jest.js │ ├── package.json │ ├── README.md │ └── CHANGELOG.md ├── eslint-config-react │ ├── test │ │ ├── .babelrc.json │ │ ├── rules │ │ │ ├── react-missing-import.js │ │ │ ├── react-jsx-extension.jsx │ │ │ ├── react-no-unused.js │ │ │ └── react-hooks.js │ │ ├── samples │ │ │ └── my-component │ │ │ │ ├── MyComponent.test.js │ │ │ │ ├── MyComponent.js │ │ │ │ └── MyComponent.old.js │ │ └── .eslintrc.json │ ├── lib │ │ ├── rules │ │ │ ├── react-hooks.js │ │ │ └── react.js │ │ └── index.js │ ├── package.json │ ├── README.md │ └── CHANGELOG.md ├── eslint-config-react-web-a11y │ ├── lib │ │ ├── index.js │ │ └── rules │ │ │ └── jsx-a11y.js │ ├── test │ │ ├── .babelrc.json │ │ └── .eslintrc.json │ ├── package.json │ ├── README.md │ └── CHANGELOG.md └── eslint-config-vue │ ├── lib │ └── index.js │ ├── test │ ├── .eslintrc.json │ └── rules │ │ ├── vue-no-textarea-mustache.vue │ │ ├── vue-no-template-key.vue │ │ ├── vue-no-shared-component-data.vue │ │ ├── vue-no-reserved-keys.vue │ │ ├── vue-no-dupe-keys.vue │ │ ├── vue-no-dupe-attributes.vue │ │ ├── vue-return-in-computed-property.vue │ │ ├── vue-no-use-vif-with-vfor.vue │ │ ├── vue-no-side-effects-in-computed-properties.vue │ │ ├── vue-no-async-computed-properties.vue │ │ ├── vue-no-unused-components.vue │ │ ├── vue-require-valid-default-prop.vue │ │ └── vue-valid-directives.vue │ ├── package.json │ ├── README.md │ └── CHANGELOG.md ├── .huskyrc ├── commitlint.config.js ├── .eslintrc.json ├── jest.config.js ├── .editorconfig ├── lerna.json ├── .github └── workflows │ └── node-ci.yml ├── index.test.js ├── package.json ├── LICENSE ├── CONTRIBUTING.md ├── MIGRATION.md └── README.md /.npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps=true 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | npm-debug.* 3 | lerna-debug.log 4 | coverage/ 5 | -------------------------------------------------------------------------------- /packages/eslint-config-base/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('./es2020'); 4 | -------------------------------------------------------------------------------- /packages/eslint-config-base/cjs/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('./es2020'); 4 | -------------------------------------------------------------------------------- /packages/eslint-config-base/esm/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('./es2020'); 4 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('./rn-062'); 4 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('./rn-062/ios'); 4 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/no-unresolved/ios-only/MyComponent.ios.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/no-unresolved/android-only/MyComponent.android.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/no-unresolved/both-platforms/MyComponent.ios.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/eslint-config-babel/test/.babelrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@moxy/babel-preset/lib" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/android.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('./rn-062/android'); 4 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/no-unresolved/both-platforms/MyComponent.android.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/__mocks__/other-sample-mock.js: -------------------------------------------------------------------------------- 1 | export default { 2 | foo: jest.fn(), 3 | }; 4 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/jest.setup.js: -------------------------------------------------------------------------------- 1 | const foo = { 2 | bar: () => {}, 3 | }; 4 | 5 | jest.spyOn(foo, 'log'); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/.babelrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@moxy/babel-preset/lib", { "react": true }] 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.huskyrc: -------------------------------------------------------------------------------- 1 | { 2 | "hooks": { 3 | "pre-commit": "lint-staged", 4 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '@commitlint/config-conventional', 6 | ], 7 | }; 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/test.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/test.ts: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/__mocks__/sample-mock.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | foo: jest.fn(), 5 | }; 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/test/test.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/tests/test.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/__tests__/test.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/non-test-file.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/test-file.test.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-cjs/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "../../../cjs/es2015" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-esm/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "../../../esm/es2015" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/non-test-file.spec.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/test/non-test-file.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/test/test-file.test.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/tests/non-test-file.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/tests/test-file.test.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/jest.setup.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const foo = { 4 | bar: () => {}, 5 | }; 6 | 7 | jest.spyOn(foo, 'log'); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/test.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/__tests__/non-test-file.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/__tests__/test-file.test.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/test/non-test-file.spec.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/tests/non-test-file.spec.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/__tests__/non-test-file.spec.js: -------------------------------------------------------------------------------- 1 | require('foo'); 2 | 3 | it('should be 1', () => { 4 | expect(1).toBe(1); 5 | }); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/__tests__/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/non-test-file.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/test-file.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/tests/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-cjs/contrived.bad-syntax.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | import fs from 'fs'; 4 | 5 | fs.readFileSync('/path/to/file'); 6 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/non-test-file.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/test/non-test-file.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/test/test-file.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/tests/non-test-file.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/test-patterns.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = [ 4 | '**/?(*.)test.[jt]s', 5 | '**/__mocks__/**/*.js', 6 | '**/jest.setup.js', 7 | ]; 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/__tests__/non-test-file.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/__tests__/test-file.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/test/non-test-file.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/tests/non-test-file.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/tests/test-file.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015/commitlint.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '@commitlint/config-conventional', 6 | ], 7 | }; 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/__tests__/non-test-file.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('foo'); 4 | 5 | it('should be 1', () => { 6 | expect(1).toBe(1); 7 | }); 8 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-cjs/commitlint.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '@commitlint/config-conventional', 6 | ], 7 | }; 8 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-esm/commitlint.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '@commitlint/config-conventional', 6 | ], 7 | }; 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-cjs/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "@moxy/eslint-config-base/cjs", 5 | "../../.." 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/samples/project-esm/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "@moxy/eslint-config-base/esm", 5 | "../../.." 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /packages/eslint-config-base/cjs/es2015.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/cjs', 6 | '../es2015', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/cjs/es2016.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/cjs', 6 | '../es2016', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/cjs/es2017.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/cjs', 6 | '../es2017', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/cjs/es2018.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/cjs', 6 | '../es2018', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/cjs/es2019.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/cjs', 6 | '../es2019', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/cjs/es2020.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/cjs', 6 | '../es2020', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/esm/es2015.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/esm', 6 | '../es2015', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/esm/es2016.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/esm', 6 | '../es2016', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/esm/es2017.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/esm', 6 | '../es2017', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/esm/es2018.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/esm', 6 | '../es2018', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/esm/es2019.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/esm', 6 | '../es2019', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/esm/es2020.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../lib/modules/esm', 6 | '../es2020', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2016/contrived.good.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | 'use strict'; 4 | 5 | function pow(x) { 6 | return x ** 2; 7 | } 8 | 9 | pow(); 10 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "../../../es2015" 5 | ], 6 | "rules": { 7 | "no-implicit-globals": "off" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2016/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "../../../es2016" 5 | ], 6 | "rules": { 7 | "no-implicit-globals": "off" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2017/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "../../../es2017" 5 | ], 6 | "rules": { 7 | "no-implicit-globals": "off" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2018/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "../../../es2018" 5 | ], 6 | "rules": { 7 | "no-implicit-globals": "off" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2019/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "../../../es2019" 5 | ], 6 | "rules": { 7 | "no-implicit-globals": "off" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-060/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-059', 6 | '../lib/rules/platforms/rn-060/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-060/ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-059/ios', 6 | '../lib/rules/platforms/rn-060/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-061/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-060', 6 | '../lib/rules/platforms/rn-061/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-061/ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-060/ios', 6 | '../lib/rules/platforms/rn-061/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-062/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-061', 6 | '../lib/rules/platforms/rn-062/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-062/ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-061/ios', 6 | '../lib/rules/platforms/rn-062/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "node": true 5 | }, 6 | "extends": [ 7 | "./packages/eslint-config-base/cjs/es2015", 8 | "./packages/eslint-config-jest" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/eslint-config-base/es2019.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | './es2018', 6 | ].map(require.resolve), 7 | parserOptions: { 8 | ecmaVersion: 2019, 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/rules/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "node": true 5 | }, 6 | "extends": [ 7 | "@moxy/eslint-config-base", 8 | "../.." 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/rules/react-missing-import.js: -------------------------------------------------------------------------------- 1 | // `react-in-jsx-scope` - prevent missing React when using JSX 2 | // --------------------------------------------------------------------- 3 | const div =
foo
; 4 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2016/contrived.bad.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | 'use strict'; 4 | 5 | // Test restricted properties 6 | function pow(x) { 7 | return Math.pow(x, 2); 8 | } 9 | 10 | pow(); 11 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-060/android.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-059/android', 6 | '../lib/rules/platforms/rn-060/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-061/android.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-060/android', 6 | '../lib/rules/platforms/rn-061/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-062/android.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | '../rn-061/android', 6 | '../lib/rules/platforms/rn-062/any', 7 | ].map(require.resolve), 8 | }; 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/.babelrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@moxy/babel-preset/lib", 5 | { 6 | "react": true 7 | } 8 | ] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2019/contrived.good.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | 'use strict'; 4 | 5 | const doSomething = () => {}; 6 | 7 | try { 8 | doSomething(); 9 | } catch { 10 | /* Empty */ 11 | } 12 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/test/.babelrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@moxy/babel-preset/lib", 5 | { 6 | "react": true 7 | } 8 | ] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/eslint-config-react-web-a11y/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | plugins: [ 5 | 'jsx-a11y', 6 | ], 7 | extends: [ 8 | './rules/jsx-a11y', 9 | ].map(require.resolve), 10 | }; 11 | -------------------------------------------------------------------------------- /packages/eslint-config-react-web-a11y/test/.babelrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@moxy/babel-preset/lib", 5 | { 6 | "react": true 7 | } 8 | ] 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2018/contrived.good.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | 'use strict'; 4 | 5 | async function fetchData(params) { 6 | await Promise.resolve({ some: 'data', ...params }); 7 | } 8 | 9 | fetchData(); 10 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/rules/es6-esm.js: -------------------------------------------------------------------------------- 1 | // `no-duplicate-imports` - disallow duplicate module imports 2 | // --------------------------------------------------------------------- 3 | import { linter } from 'eslint'; 4 | import { cliEngine } from 'eslint'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/samples/my-component/MyComponent.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View } from 'react-native'; 3 | 4 | // Should ignore react-native/no-inline-styles 5 | const MyComponent = () => ; 6 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | 'plugin:vue/essential', 6 | require.resolve('@vue/eslint-config-prettier'), 7 | ], 8 | plugins: [ 9 | 'vue', 10 | ], 11 | }; 12 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/samples/my-component/MyComponent.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | // Should ignore react/jsx-no-bind and react/prop-types 4 | const MyComponent = ({ message }) =>
{} }>{ message }
; 5 | 6 | export default MyComponent; 7 | -------------------------------------------------------------------------------- /packages/eslint-config-base/es2017.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | './es2016', 6 | ].map(require.resolve), 7 | env: { 8 | es2017: true, 9 | }, 10 | parserOptions: { 11 | ecmaVersion: 2017, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/eslint-config-base/es2020.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | './es2019', 6 | ].map(require.resolve), 7 | env: { 8 | es2020: true, 9 | }, 10 | parserOptions: { 11 | ecmaVersion: 2020, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { compose, baseConfig } = require('@moxy/jest-config-base'); 4 | 5 | module.exports = compose( 6 | baseConfig('node'), 7 | (config) => { 8 | config.testMatch = ['**/index.test.js']; 9 | 10 | return config; 11 | } 12 | ); 13 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/rules/strict.js: -------------------------------------------------------------------------------- 1 | // Strict mode - http://eslint.org/docs/rules/#strict-mode 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Require or disallow strict mode directives 8 | strict: ['error', 'global'], 9 | }, 10 | }; 11 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "browser": true 5 | }, 6 | "extends": [ 7 | "@moxy/eslint-config-base/esm", 8 | ".." 9 | ], 10 | "rules": { 11 | "no-unused-vars": "off" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/rules/strict.js: -------------------------------------------------------------------------------- 1 | // `strict` - require or disallow strict mode directives 2 | // --------------------------------------------------------------------- 3 | // Bad 4 | (function foo() { 5 | 'use strict'; 6 | })(); 7 | // Good 8 | // Use `'use strict;` at the top of the file 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/test/samples/my-component/MyComponent.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { TouchableOpacity } from 'react-native'; 3 | 4 | // Should ignore react-native-a11y/has-accessibility-hint 5 | const MyComponent = () => ; 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [{*.md,*.snap}] 12 | trim_trailing_whitespace = false 13 | 14 | [{package.json,*.yml}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-unused-styles/imported-styles/function-component/MyComponent.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View } from 'react-native'; 3 | import styles from './styles'; 4 | 5 | const MyComponent = () => ; 6 | 7 | export default MyComponent; 8 | 9 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/no-unresolved/ios-only/index.js: -------------------------------------------------------------------------------- 1 | // `no-unresolved` - Ensure imports point to a file/module that can be resolved 2 | // -------------------------------------------------------------------- 3 | // Bad: should fail when only `.ios.js` module exists 4 | import MyComponent from './MyComponent'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/MyComponent.ios.js: -------------------------------------------------------------------------------- 1 | // `split-platform-components` - Enforce using platform specific filenames when necessary 2 | // -------------------------------------------------------------------- 3 | // Good: iOS-specific component being used in `.ios.js` file 4 | import { ComponentIOS } from 'react-native'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/no-unresolved/android-only/index.js: -------------------------------------------------------------------------------- 1 | // `no-unresolved` - Ensure imports point to a file/module that can be resolved 2 | // -------------------------------------------------------------------- 3 | // Bad: should fail when only `.android.js` module exists 4 | import MyComponent from './MyComponent'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/MyIOSComponent.js: -------------------------------------------------------------------------------- 1 | // `split-platform-components` - Enforce using platform specific filenames when necessary 2 | // -------------------------------------------------------------------- 3 | // Bad: iOS-specific components should be placed in `.ios.js` files 4 | import { ComponentIOS } from 'react-native'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/rules/react-jsx-extension.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | // `jsx-filename-extension` - restrict file extensions that may contain JSX 4 | // --------------------------------------------------------------------- 5 | class MyComponent extends Component { 6 | render() { 7 | return
; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/eslint-config-base/es2016.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | './es2015', 6 | ].map(require.resolve), 7 | parserOptions: { 8 | ecmaVersion: 2016, 9 | }, 10 | rules: { 11 | // Disallow certain properties on certain objects 12 | 'prefer-exponentiation-operator': 'error', 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-059/ios.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const baseConfig = require('./base-config'); 4 | 5 | module.exports = Object.assign( 6 | { 7 | extends: [ 8 | '../lib/rules/platforms/rn-059/any', 9 | '../lib/rules/platforms/rn-059/ios', 10 | ].map(require.resolve), 11 | }, 12 | baseConfig 13 | ); 14 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/MyComponent.android.js: -------------------------------------------------------------------------------- 1 | // `split-platform-components` - Enforce using platform specific filenames when necessary 2 | // -------------------------------------------------------------------- 3 | // Good: Android-specific component being used in `.android.js` file 4 | import { ComponentAndroid } from 'react-native'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/MyIOSComponent.android.js: -------------------------------------------------------------------------------- 1 | // `split-platform-components` - Enforce using platform specific filenames when necessary 2 | // -------------------------------------------------------------------- 3 | // Bad: iOS-specific components should be placed in `.ios.js` files 4 | import { ComponentIOS } from 'react-native'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/no-unresolved/no-platform/index.js: -------------------------------------------------------------------------------- 1 | // `no-unresolved` - Ensure imports point to a file/module that can be resolved 2 | // -------------------------------------------------------------------- 3 | // Bad: should fail when neither `.ios.js` and `.android.js` modules exist 4 | import MyComponent from './MyComponent'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/MyAndroidComponent.js: -------------------------------------------------------------------------------- 1 | // `split-platform-components` - Enforce using platform specific filenames when necessary 2 | // -------------------------------------------------------------------- 3 | // Bad: Android-specific components should be placed in `.android.js` files 4 | import { ComponentAndroid } from 'react-native'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/no-unresolved/both-platforms/index.js: -------------------------------------------------------------------------------- 1 | // `no-unresolved` - Ensure imports point to a file/module that can be resolved 2 | // -------------------------------------------------------------------- 3 | // Good: should not fail when both `.ios.js` and `.android.js` modules exist 4 | import MyComponent from './MyComponent'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-059/android.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const baseConfig = require('./base-config'); 4 | 5 | module.exports = Object.assign( 6 | { 7 | extends: [ 8 | '../lib/rules/platforms/rn-059/android', 9 | '../lib/rules/platforms/rn-059/any', 10 | ].map(require.resolve), 11 | }, 12 | baseConfig 13 | ); 14 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/MyAndroidComponent.ios.js: -------------------------------------------------------------------------------- 1 | // `split-platform-components` - Enforce using platform specific filenames when necessary 2 | // -------------------------------------------------------------------- 3 | // Bad: Android-specific components should be placed in `.android.js` files 4 | import { ComponentAndroid } from 'react-native'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/split-platform-components/MyComponent.js: -------------------------------------------------------------------------------- 1 | // `split-platform-components` - Enforce using platform specific filenames when necessary 2 | // -------------------------------------------------------------------- 3 | // Bad: Don't mix Android and iOS-specific components in the same file 4 | import { ComponentAndroid, ComponentIOS } from 'react-native'; 5 | -------------------------------------------------------------------------------- /packages/eslint-config-base/es2018.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | extends: [ 5 | './es2017', 6 | ].map(require.resolve), 7 | parserOptions: { 8 | ecmaVersion: 2018, 9 | }, 10 | rules: { 11 | // Require object spread properties to be used instead of Object.assign() 12 | 'prefer-object-spread': 'error', 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-textarea-mustache.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | -------------------------------------------------------------------------------- /packages/eslint-config-babel/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "browser": true 5 | }, 6 | "extends": [ 7 | "@moxy/eslint-config-base/esm", 8 | ".." 9 | ], 10 | "parserOptions": { 11 | "babelOptions": { 12 | "configFile": "./packages/eslint-config-babel/test/.babelrc.json" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/eslint-config-babel/test/samples/my-class/MyClass.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | function fetchData() { 4 | return import('foo'); 5 | } 6 | 7 | class MyClass { 8 | myObject = {}; 9 | 10 | foo = () => this.bar(); 11 | 12 | bar() { 13 | this.myObject?.foo(); 14 | 15 | return fetchData(); 16 | } 17 | } 18 | 19 | export default MyClass; 20 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-unused-styles/imported-styles/class-component/MyComponent.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { View } from 'react-native'; 3 | import styles from './styles'; 4 | 5 | class MyComponent extends Component { 6 | render() { 7 | return ; 8 | } 9 | } 10 | 11 | export default MyComponent; 12 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/rules/node.js: -------------------------------------------------------------------------------- 1 | // Node.js & CommonJS - http://eslint.org/docs/rules/#nodejs-and-commonjs 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Enforces error handling in callbacks 8 | 'handle-callback-err': 'warn', 9 | // Disallow new operators with calls to require 10 | 'no-new-require': 'error', 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/rules/import.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | rules: { 5 | // Last import should have a newline after 6 | 'import/newline-after-import': ['error', { count: 1 }], 7 | // Order imports 8 | 'import/order': ['error', { 9 | groups: ['builtin', 'external', 'parent', 'sibling', 'index'], 10 | }], 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-esm/contrived.good.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | import fs from 'fs'; 4 | import foo from 'foo'; 5 | import foobar from '../../foobar'; 6 | import baz from '../baz'; 7 | import bar from './bar/baz'; 8 | import index from './'; 9 | 10 | fs.readFileSync('/path/to/file'); 11 | 12 | foo(); 13 | 14 | foobar(); 15 | baz(); 16 | 17 | bar(); 18 | 19 | index(); 20 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/env.js: -------------------------------------------------------------------------------- 1 | // Rule `no-undef` should be ignored for globals. 2 | // `Intl` ought to be in the list as well because it is defined in React Native. 3 | // However, eslint-plugin-react-native-globals does not include it yet. 4 | const globals = [ 5 | __DEV__, 6 | fetch, 7 | global, 8 | window, // Points to global 9 | console, 10 | alert, 11 | process, 12 | ]; 13 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-059/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const baseConfig = require('./base-config'); 4 | 5 | module.exports = Object.assign( 6 | { 7 | extends: [ 8 | '../lib/rules/platforms/rn-059/android', 9 | '../lib/rules/platforms/rn-059/ios', 10 | '../lib/rules/platforms/rn-059/any', 11 | ].map(require.resolve), 12 | }, 13 | baseConfig 14 | ); 15 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/modules/cjs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | env: { 5 | commonjs: true, 6 | }, 7 | parserOptions: { 8 | sourceType: 'script', 9 | }, 10 | rules: { 11 | // Report AMD require and define calls 12 | 'import/no-amd': 'error', 13 | // Report CommonJS require calls and module.exports or exports.* 14 | 'import/no-commonjs': 'off', 15 | }, 16 | }; 17 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/lib/rules/platform-specific-components.js: -------------------------------------------------------------------------------- 1 | // import plugin - https://github.com/benmosher/eslint-plugin-import/ 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Ensure imports point to a file/module that can be resolved 8 | // Issues: 9 | // - https://github.com/Intellicode/eslint-plugin-react-native/issues/32 10 | 'import/no-unresolved': 'error', 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/eslint-config-react/lib/rules/react-hooks.js: -------------------------------------------------------------------------------- 1 | // React Hooks plugin - https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Checks Rules of Hooks: https://reactjs.org/docs/hooks-rules.html 8 | 'react-hooks/rules-of-hooks': 'error', 9 | // Checks effect's dependencies 10 | 'react-hooks/exhaustive-deps': 'warn', 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-cjs/contrived.bad.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | 'use strict'; 4 | 5 | // Test imports with different groups and order 6 | const fs = require('fs'); 7 | const index = require('./'); 8 | const foobar = require('../../foobar'); 9 | const foo = require('foo'); 10 | const barbaz = require('./bar/baz'); 11 | const baz = require('../baz'); 12 | fs.read(foo); 13 | 14 | foobar(); 15 | baz(); 16 | barbaz(); 17 | index(); 18 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-cjs/contrived.good.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | 'use strict'; 4 | 5 | const fs = require('fs'); 6 | const foo = require('foo'); 7 | const foobar = require('../../foobar'); 8 | const baz = require('../baz'); 9 | const bar = require('./bar/baz'); 10 | const index = require('./'); 11 | 12 | fs.readFileSync('/path/to/file'); 13 | 14 | foo(); 15 | 16 | foobar(); 17 | baz(); 18 | 19 | bar(); 20 | 21 | index(); 22 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2017/contrived.good.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | 'use strict'; 4 | 5 | function fnWithManyArgs(x, y, 6 | z, w) { 7 | return x + y + z + w; 8 | } 9 | 10 | fnWithManyArgs( 11 | 0.3, 12 | 0.2, 13 | 0.3, 14 | 0.5, 15 | ); 16 | 17 | // ------------------------------------------------- 18 | 19 | async function fetchData() { 20 | await Promise.resolve({ some: 'data' }); 21 | } 22 | 23 | fetchData(); 24 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "@moxy/eslint-config-base/esm", 5 | "@moxy/eslint-config-babel", 6 | "@moxy/eslint-config-react", 7 | ".." 8 | ], 9 | "parserOptions": { 10 | "babelOptions": { 11 | "configFile": "./packages/eslint-config-react-native/test/.babelrc.json" 12 | } 13 | }, 14 | "rules": { 15 | "no-unused-vars": "off" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-inline-styles.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Text } from 'react-native'; 3 | 4 | // `no-inline-styles` - Detect inline styles in components 5 | // -------------------------------------------------------------------- 6 | // Bad 7 | { 8 | const MyComponent = () => MOXY; 9 | } 10 | // Good 11 | { 12 | const MyComponent = ({ fontSize }) => MOXY; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-template-key.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 14 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/lib/rules/platforms/rn-061/any.js: -------------------------------------------------------------------------------- 1 | // React Native A11y plugin - https://github.com/FormidableLabs/eslint-plugin-react-native-a11y 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Enforce accessibilityState property value is valid 8 | // Introduced in React Native v0.61: https://reactnative.dev/docs/0.61/accessibility#accessibilitystate-android-ios 9 | 'react-native-a11y/has-valid-accessibility-state': 'error', 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | "packages/*" 4 | ], 5 | "version": "13.1.0", 6 | "command": { 7 | "bootstrap": { 8 | "hoist": true 9 | }, 10 | "version": { 11 | "conventionalCommits": true, 12 | "changelogPreset": "conventionalcommits", 13 | "message": "chore(release): %v" 14 | } 15 | }, 16 | "ignoreChanges": [ 17 | "**/?(*.)test.js", 18 | "**/__mocks__/**", 19 | "**/*.md" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/modules/esm.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | parserOptions: { 5 | sourceType: 'module', 6 | }, 7 | rules: { 8 | // Report AMD require and define calls 9 | 'import/no-amd': 'error', 10 | // Report CommonJS require calls and module.exports or exports.* 11 | 'import/no-commonjs': ['error', { allowConditionalRequire: false }], 12 | // Imports should be at top of the module 13 | 'import/first': 'error', 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-raw-text.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Text, View } from 'react-native'; 3 | 4 | // `no-raw-text` - Detect raw text outside of Text component 5 | // -------------------------------------------------------------------- 6 | // Bad 7 | { 8 | const MyComponent = () => MOXY; 9 | } 10 | // Good 11 | { 12 | const MyComponent = () => MOXY; 13 | } 14 | // Also good 15 | { 16 | const MyComponent = () => MOXY; 17 | } 18 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-unused-styles/imported-styles/class-component/styles.js: -------------------------------------------------------------------------------- 1 | import { StyleSheet } from 'react-native'; 2 | 3 | // `no-unused-styles` - Detect unused StyleSheet rules in React components 4 | // -------------------------------------------------------------------- 5 | // Doesn't fail on 'bar' yet because of https://github.com/Intellicode/eslint-plugin-react-native/issues/165 6 | const styles = StyleSheet.create({ 7 | bar: {}, 8 | foo: {}, 9 | }); 10 | 11 | export default styles; 12 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-unused-styles/imported-styles/function-component/styles.js: -------------------------------------------------------------------------------- 1 | import { StyleSheet } from 'react-native'; 2 | 3 | // `no-unused-styles` - Detect unused StyleSheet rules in React components 4 | // -------------------------------------------------------------------- 5 | // Doesn't fail on 'bar' yet because of https://github.com/Intellicode/eslint-plugin-react-native/issues/165 6 | const styles = StyleSheet.create({ 7 | bar: {}, 8 | foo: {}, 9 | }); 10 | 11 | export default styles; 12 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/rn-059/base-config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const testFilePatterns = require('@moxy/eslint-config-base/lib/test-patterns'); 4 | 5 | module.exports = { 6 | plugins: [ 7 | 'react-native-a11y', 8 | ], 9 | overrides: [ 10 | { 11 | files: testFilePatterns, 12 | // Disable rules that are cumbersome in tests 13 | rules: { 14 | 'react-native-a11y/has-accessibility-hint': 0, 15 | }, 16 | }, 17 | ], 18 | }; 19 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-shared-component-data.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "extends": [ 4 | "@moxy/eslint-config-base/esm", 5 | "@moxy/eslint-config-babel", 6 | "@moxy/eslint-config-react", 7 | ".." 8 | ], 9 | "parserOptions": { 10 | "babelOptions": { 11 | "configFile": "./packages/eslint-config-react-native-a11y/test/.babelrc.json" 12 | } 13 | }, 14 | "rules": { 15 | "no-unused-vars": "off", 16 | "react/jsx-no-bind": "off" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/eslint-config-react-web-a11y/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "browser": true 5 | }, 6 | "extends": [ 7 | "@moxy/eslint-config-base/esm", 8 | "@moxy/eslint-config-babel", 9 | "@moxy/eslint-config-react", 10 | ".." 11 | ], 12 | "parserOptions": { 13 | "babelOptions": { 14 | "configFile": "./packages/eslint-config-react-web-a11y/test/.babelrc.json" 15 | } 16 | }, 17 | "rules": { 18 | "no-unused-vars": "off" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-unused-styles/same-file-styles/function-component.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment } from 'react'; 2 | import { StyleSheet, View } from 'react-native'; 3 | 4 | // `no-unused-styles` - Detect unused StyleSheet rules in React components 5 | // -------------------------------------------------------------------- 6 | // Bad: fails on 'bar' 7 | const styles = StyleSheet.create({ 8 | bar: {}, 9 | foo: {}, 10 | }); 11 | 12 | { 13 | const MyComponent = () => ( 14 | 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-reserved-keys.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 24 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/rules/jsdoc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Bad 4 | { 5 | /** 6 | * Add two numbers. 7 | * @param {Number} num The first number. 8 | * @returns The sum of the two numbers. 9 | */ 10 | const add = (num1, num2) => num1 + num2; 11 | } 12 | // Good 13 | { 14 | /** 15 | * Add two numbers. 16 | * 17 | * @param {number} num1 - The first number. 18 | * @param {number} num2 - The second number. 19 | * @returns {number} The sum of the two numbers. 20 | */ 21 | const add = (num1, num2) => num1 + num2; 22 | } 23 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-unused-styles/same-file-styles/function-component-fragment.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment } from 'react'; 2 | import { StyleSheet, View } from 'react-native'; 3 | 4 | // `no-unused-styles` - Detect unused StyleSheet rules in React components 5 | // -------------------------------------------------------------------- 6 | const styles = StyleSheet.create({ 7 | bar: {}, 8 | foo: {}, 9 | }); 10 | 11 | { 12 | const MyComponent = () => ( 13 | <> 14 | 15 | 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/lib/rules/platforms/rn-062/any.js: -------------------------------------------------------------------------------- 1 | // React Native A11y plugin - https://github.com/FormidableLabs/eslint-plugin-react-native-a11y 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Enforce accessibilityValue property value is valid 8 | // Introduced in React Native v0.62: 9 | // - https://reactnative.dev/docs/accessibility#accessibilityvalue-android-ios 10 | // - https://reactnative.dev/blog/2020/03/26/version-0.62#other-improvements 11 | 'react-native-a11y/has-valid-accessibility-value': 'error', 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-dupe-keys.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 27 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-unused-styles/same-file-styles/class-component.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment, Component } from 'react'; 2 | import { StyleSheet, View } from 'react-native'; 3 | 4 | // `no-unused-styles` - Detect unused StyleSheet rules in React components 5 | // -------------------------------------------------------------------- 6 | // Bad: fails on 'bar' 7 | const styles = StyleSheet.create({ 8 | bar: {}, 9 | foo: {}, 10 | }); 11 | 12 | { 13 | class MyComponent extends Component { 14 | render() { 15 | return ; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/lib/rules/platforms/rn-060/any.js: -------------------------------------------------------------------------------- 1 | // React Native A11y plugin - https://github.com/FormidableLabs/eslint-plugin-react-native-a11y 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Enforce both accessibilityActions and onAccessibilityAction props are valid 8 | // Introduced in React Native v0.60: 9 | // - https://reactnative.dev/docs/0.60/accessibility#accessibility-actions 10 | // - https://reactnative.dev/blog/2019/07/03/version-60#focus-on-accessibility 11 | 'react-native-a11y/has-valid-accessibility-actions': 'error', 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-dupe-attributes.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015-esm/contrived.bad.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | // Test unnecessary `use strict` 3 | 4 | 'use strict'; 5 | 6 | // Test imports with different groups and order 7 | import fs from 'fs'; 8 | import index from './'; 9 | import foobar from '../../foobar'; 10 | import foo from 'foo'; 11 | import barbaz from './bar/baz'; 12 | import baz from '../baz'; 13 | fs.read(foo); 14 | 15 | foobar(); 16 | baz(); 17 | barbaz(); 18 | index(); 19 | 20 | // Test error when using require 21 | 22 | const bar = require('foo/bar'); 23 | 24 | // Test imports in body of module 25 | import biz from '../biz'; 26 | 27 | bar(); 28 | biz(); 29 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "browser": true 5 | }, 6 | "extends": [ 7 | "@moxy/eslint-config-base/esm", 8 | "@moxy/eslint-config-babel", 9 | ".." 10 | ], 11 | "parserOptions": { 12 | "babelOptions": { 13 | "configFile": "./packages/eslint-config-react/test/.babelrc.json" 14 | } 15 | }, 16 | "overrides": [ 17 | { 18 | "files": "./**/*.js", 19 | "excludedFiles": "./rules/react-no-unused.js", 20 | "rules": { 21 | "no-unused-vars": "off" 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-single-element-style-arrays.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View } from 'react-native'; 3 | 4 | // `no-single-element-style-arrays` - No Single Element Style Arrays are allowed 5 | // -------------------------------------------------------------------- 6 | const styles = StyleSheet.create({ 7 | a: {}, 8 | b: {}, 9 | }); 10 | 11 | // Bad 12 | { 13 | const MyComponent = () => ; 14 | } 15 | // Also bad 16 | { 17 | const MyComponent = () => ; 18 | } 19 | // Good 20 | { 21 | const MyComponent = () => ; 22 | } 23 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/lib/rules/platforms/rn-059/ios.js: -------------------------------------------------------------------------------- 1 | // React Native A11y plugin - https://github.com/FormidableLabs/eslint-plugin-react-native-a11y 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Enforce accessibilityTraits property value is valid 8 | // Removed from React Native v0.60+: https://reactnative.dev/docs/0.60/view#accessibilitytraits 9 | 'react-native-a11y/has-valid-accessibility-traits': 'error', 10 | // Enforce that certain elements use accessibilityIgnoresInvertColors to avoid being inverted by device color settings 11 | 'react-native-a11y/has-valid-accessibility-ignores-invert-colors': 'error', 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/rules/variables-no-unused.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // `no-unused-vars` - disallow unused variables 4 | // --------------------------------------------------------------------- 5 | // Bad on object rest 6 | { 7 | const x = 1; 8 | const { y } = { y: 1, z: 2 }; 9 | 10 | Math.floor(x); 11 | } 12 | // Good on object spread 13 | { 14 | const x = 1; 15 | const { y, ...other } = { y: 1, z: 2 }; 16 | 17 | Math.floor(x); 18 | Object.keys(other); 19 | } 20 | // Bad on args spread 21 | (function (x, ...other) { 22 | Math.floor(x); 23 | })(1, 2, 3); 24 | // Good on args spread 25 | (function (x, ...other) { 26 | other.forEach((val) => Math.floor(val)); 27 | })(1, 2, 3); 28 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const testFilePatterns = require('@moxy/eslint-config-base/lib/test-patterns'); 4 | 5 | module.exports = { 6 | overrides: [ 7 | { 8 | files: testFilePatterns, 9 | plugins: [ 10 | 'jest', 11 | ], 12 | env: { 13 | 'jest/globals': true, 14 | }, 15 | extends: [ 16 | './rules/jest', 17 | ].map(require.resolve), 18 | rules: { 19 | // Allow `require` as it's needed for when we are using `jest.doMock` and friends 20 | 'import/no-commonjs': 0, 21 | }, 22 | }, 23 | ], 24 | }; 25 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-unused-styles/same-file-styles/class-component-fragment.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment, Component } from 'react'; 2 | import { StyleSheet, View } from 'react-native'; 3 | 4 | // `no-unused-styles` - Detect unused StyleSheet rules in React components 5 | // -------------------------------------------------------------------- 6 | // Bad: fails on 'bar' 7 | const styles = StyleSheet.create({ 8 | bar: {}, 9 | foo: {}, 10 | }); 11 | 12 | { 13 | class MyComponent extends Component { 14 | render() { 15 | return ( 16 | <> 17 | 18 | 19 | ); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-return-in-computed-property.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 27 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/lib/rules/jest.js: -------------------------------------------------------------------------------- 1 | // Jest: https://github.com/facebook/jest/tree/master/packages/eslint-plugin-jest 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Disallow disabled Tests 8 | 'jest/no-disabled-tests': 'warn', 9 | // No focused tests 10 | 'jest/no-focused-tests': 'error', 11 | // No identical title 12 | 'jest/no-identical-title': 'error', 13 | // Prefer toHaveLength() over toBe() 14 | 'jest/prefer-to-have-length': 'error', 15 | // Ensure expect is called correctly 16 | 'jest/valid-expect': 'error', 17 | // Enforce lowercase test names 18 | 'jest/lowercase-name': ['error', { 19 | ignoreTopLevelDescribe: true, 20 | }], 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const testFilePatterns = require('@moxy/eslint-config-base/lib/test-patterns'); 4 | 5 | module.exports = { 6 | extends: [ 7 | './rules/react-native', 8 | './rules/platform-specific-components', 9 | ].map(require.resolve), 10 | plugins: [ 11 | 'react-native', 12 | ], 13 | env: { 14 | 'react-native/react-native': true, 15 | }, 16 | settings: { 17 | 'import/resolver': 'react-native', 18 | }, 19 | overrides: [ 20 | { 21 | files: testFilePatterns, 22 | // Disable rules that are cumbersome in tests 23 | rules: { 24 | 'react-native/no-inline-styles': 0, 25 | }, 26 | }, 27 | ], 28 | }; 29 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/lib/rules/platforms/rn-059/android.js: -------------------------------------------------------------------------------- 1 | // React Native A11y plugin - https://github.com/FormidableLabs/eslint-plugin-react-native-a11y 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Enforce accessibilityComponentType property value is valid 8 | // Removed from React Native v0.60+: https://reactnative.dev/docs/0.60/view#accessibilitycomponenttype 9 | 'react-native-a11y/has-valid-accessibility-component-type': 'error', 10 | // Enforce accessibilityLiveRegion prop values must be valid 11 | 'react-native-a11y/has-valid-accessibility-live-region': 'error', 12 | // Enforce importantForAccessibility property value is valid 13 | 'react-native-a11y/has-valid-important-for-accessibility': 'error', 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/rules/react-no-unused.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | // `jsx-uses-react` - prevent React to be incorrectly marked as unused 4 | // --------------------------------------------------------------------- 5 | // Should not give an error 6 | { 7 | class MyComponent extends Component { 8 | render() { 9 | return
foo
; 10 | } 11 | } 12 | 13 | console.log(MyComponent); 14 | } 15 | 16 | // `jsx-uses-vars` - prevent variables used in JSX to be incorrectly marked as unused 17 | // --------------------------------------------------------------------- 18 | // Should not give an error 19 | { 20 | const isLoading = true; 21 | const component = ; 22 | 23 | console.log(isLoading, component); 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/node-ci.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: push 4 | 5 | jobs: 6 | prepare: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | node-version: ["12", "14"] 11 | name: "[v${{ matrix.node-version }}] check" 12 | 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v1 16 | - name: Use Node.js ${{ matrix.node-version }} 17 | uses: actions/setup-node@v1 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - name: Install dependencies 21 | run: | 22 | npm ci 23 | - name: Lint 24 | run: | 25 | npm run lint 26 | - name: Test 27 | env: 28 | CI: 1 29 | run: | 30 | npm t 31 | - name: Submit coverage 32 | uses: codecov/codecov-action@v1 33 | with: 34 | token: ${{ secrets.CODECOV_TOKEN }} 35 | -------------------------------------------------------------------------------- /index.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const path = require('path'); 4 | const eslint = require('eslint'); 5 | 6 | const cli = new eslint.CLIEngine({ 7 | useEslintrc: true, 8 | }); 9 | 10 | const report = cli.executeOnFiles(['packages/*/test/**/*.{js,jsx,ts,vue}']); 11 | const results = report.results; 12 | 13 | results.forEach((object) => { 14 | const filePath = object.filePath; 15 | const relativeFilePath = path.relative(__dirname, filePath).replace(/\\/g, '/'); 16 | 17 | it(`should pass on ${relativeFilePath}`, () => { 18 | const result = object.messages 19 | .map((message) => ({ rule: message.ruleId, severity: message.severity, line: message.line, column: message.column })) 20 | .sort((warn1, warn2) => warn1.line - warn2.line || warn1.column - warn2.column || warn1.rule.localeCompare(warn2.rule)); 21 | 22 | expect(result).toMatchSnapshot(); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /packages/eslint-config-base/es2015.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | plugins: [ 5 | 'import', 6 | 'jsdoc', 7 | ], 8 | extends: [ 9 | './lib/rules/best-practices', 10 | './lib/rules/errors', 11 | './lib/rules/es6', 12 | './lib/rules/import', 13 | './lib/rules/jsdoc', 14 | './lib/rules/node', 15 | './lib/rules/strict', 16 | './lib/rules/style', 17 | './lib/rules/variables', 18 | ].map(require.resolve), 19 | env: { 20 | es6: true, 21 | }, 22 | parserOptions: { 23 | ecmaVersion: 2015, 24 | }, 25 | overrides: [ 26 | { 27 | files: ['./*.config.js', './.eslintrc.js'], 28 | env: { 29 | node: true, 30 | }, 31 | extends: [ 32 | './lib/modules/cjs', 33 | ], 34 | }, 35 | ], 36 | }; 37 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-use-vif-with-vfor.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | -------------------------------------------------------------------------------- /packages/eslint-config-react/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const testFilePatterns = require('@moxy/eslint-config-base/lib/test-patterns'); 4 | 5 | module.exports = { 6 | extends: [ 7 | './rules/react', 8 | './rules/react-hooks', 9 | ].map(require.resolve), 10 | plugins: [ 11 | 'react', 12 | 'react-hooks', 13 | ], 14 | parserOptions: { 15 | ecmaFeatures: { 16 | jsx: true, 17 | }, 18 | }, 19 | settings: { 20 | react: { 21 | version: 'detect', // React version, "detect" automatically picks the version you have installed 22 | }, 23 | }, 24 | overrides: [ 25 | { 26 | files: testFilePatterns, 27 | // Disable rules that are cumbersome in tests 28 | rules: { 29 | 'react/jsx-no-bind': 0, 30 | 'react/prop-types': 0, 31 | }, 32 | }, 33 | ], 34 | }; 35 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/rules/node.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | 5 | // `handle-callback-err` - require error handling in callbacks 6 | // --------------------------------------------------------------------- 7 | // Not advisable 8 | { 9 | const callback = (err, value) => { 10 | console.log(value); 11 | }; 12 | } 13 | // Good 14 | { 15 | const callback = (err, value) => { 16 | if (err) { 17 | console.log('error', err); 18 | 19 | return; 20 | } 21 | 22 | console.log(value); 23 | }; 24 | } 25 | // Also good 26 | { 27 | const otherCallback = () => {}; 28 | const callback = (err, value) => otherCallback(err, value); 29 | } 30 | 31 | // `no-new-require` - disallow new operators with calls to require 32 | // --------------------------------------------------------------------- 33 | // This is not allowed because `new-cap` disallows `new require('some-module')`` 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "root", 3 | "private": true, 4 | "homepage": "https://github.com/moxystudio/eslint-config", 5 | "repository": { 6 | "type": "git", 7 | "url": "git@github.com:moxystudio/eslint-config.git" 8 | }, 9 | "scripts": { 10 | "lint": "eslint . --ignore-pattern **/test", 11 | "test": "jest", 12 | "postinstall": "lerna bootstrap", 13 | "prerelease": "npm run test && npm run lint", 14 | "release": "lerna publish", 15 | "lcov": "open coverage/lcov-report/index.html" 16 | }, 17 | "devDependencies": { 18 | "@commitlint/cli": "^9.1.2", 19 | "@commitlint/config-conventional": "^9.1.1", 20 | "@moxy/jest-config-base": "^5.0.0", 21 | "conventional-changelog-conventionalcommits": "^4.3.1", 22 | "eslint": "^7.6.0", 23 | "husky": "^4.2.3", 24 | "jest": "^26.2.2", 25 | "lerna": "^3.20.2", 26 | "lint-staged": "^10.0.7" 27 | }, 28 | "lint-staged": { 29 | "*.js": "eslint --ignore-pattern **/test" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/sort-styles.js: -------------------------------------------------------------------------------- 1 | import { StyleSheet } from 'react-native'; 2 | 3 | // `sort-styles` - Require StyleSheet keys to be sorted 4 | // -------------------------------------------------------------------- 5 | // Bad 6 | { 7 | const styles = StyleSheet.create({ 8 | a: {}, 9 | c: {}, 10 | b: {}, 11 | }); 12 | } 13 | // Also bad 14 | { 15 | const styles = StyleSheet.create({ 16 | a: { 17 | b: 'foo', 18 | a: 'foo', 19 | c: 'foo', 20 | }, 21 | c: {}, 22 | b: {}, 23 | }); 24 | } 25 | // Good: sorted alphabetically 26 | { 27 | const styles = StyleSheet.create({ 28 | a: {}, 29 | b: {}, 30 | c: {}, 31 | }); 32 | } 33 | // Also good 34 | { 35 | const styles = StyleSheet.create({ 36 | a: { 37 | a: 'foo', 38 | b: 'foo', 39 | c: 'foo', 40 | }, 41 | b: {}, 42 | c: {}, 43 | }); 44 | } 45 | -------------------------------------------------------------------------------- /packages/eslint-config-base/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@moxy/eslint-config-base", 3 | "description": "MOXY's ESLint base configuration", 4 | "version": "13.1.0", 5 | "keywords": [ 6 | "eslint-config", 7 | "eslintconfig", 8 | "eslint", 9 | "lint", 10 | "linter", 11 | "style", 12 | "base" 13 | ], 14 | "author": "André Cruz ", 15 | "homepage": "https://github.com/moxystudio/eslint-config", 16 | "repository": { 17 | "type": "git", 18 | "url": "git@github.com:moxystudio/eslint-config.git" 19 | }, 20 | "license": "MIT", 21 | "main": "index.js", 22 | "files": [ 23 | "es*.js", 24 | "esm", 25 | "cjs", 26 | "lib" 27 | ], 28 | "dependencies": { 29 | "eslint-plugin-import": "^2.22.0", 30 | "eslint-plugin-jsdoc": "^30.2.1" 31 | }, 32 | "peerDependencies": { 33 | "eslint": "^7.6.0" 34 | }, 35 | "engines": { 36 | "node": ">=10", 37 | "npm": ">=3" 38 | }, 39 | "publishConfig": { 40 | "access": "public" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-side-effects-in-computed-properties.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 19 | 32 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@moxy/eslint-config-jest", 3 | "description": "MOXY's ESLint configuration enhancer for projects that use Jest for testing", 4 | "version": "13.1.0", 5 | "keywords": [ 6 | "eslint-config", 7 | "eslintconfig", 8 | "eslint", 9 | "lint", 10 | "linter", 11 | "style", 12 | "jest-lint", 13 | "jest-eslint" 14 | ], 15 | "author": "André Cruz ", 16 | "homepage": "https://github.com/moxystudio/eslint-config", 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:moxystudio/eslint-config.git" 20 | }, 21 | "license": "MIT", 22 | "main": "lib/index.js", 23 | "files": [ 24 | "lib" 25 | ], 26 | "dependencies": { 27 | "@moxy/eslint-config-base": "^13.1.0", 28 | "eslint-plugin-jest": "^23.20.0" 29 | }, 30 | "peerDependencies": { 31 | "eslint": "^7.6.0" 32 | }, 33 | "engines": { 34 | "node": ">=10", 35 | "npm": ">=3" 36 | }, 37 | "publishConfig": { 38 | "access": "public" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/rules/variables.js: -------------------------------------------------------------------------------- 1 | // Variables - http://eslint.org/docs/rules/#variables 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Disallow identifiers from shadowing restricted names 8 | 'no-shadow-restricted-names': 'error', 9 | // Disallow the use of undeclared variables unless mentioned in /*global */ comments 10 | 'no-undef': 'error', 11 | // Disallow initializing variables to undefined 12 | 'no-undef-init': 'error', 13 | // Disallow unused variables 14 | 'no-unused-vars': ['error', { vars: 'local', args: 'after-used', ignoreRestSiblings: true }], 15 | // Disallow the use of variables before they are defined 16 | 'no-use-before-define': ['error', { 17 | functions: false, // Completly disable for functions.. it feels weird 18 | classes: false, // Disable for classes but still checks in the same scope 19 | variables: false, // Disable for variables but still checks in the same scope 20 | }], 21 | }, 22 | }; 23 | -------------------------------------------------------------------------------- /packages/eslint-config-babel/lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const babelRules = require('@babel/eslint-plugin').rules; 4 | 5 | const baseRules = Object.assign( 6 | {}, 7 | require('@moxy/eslint-config-base/lib/rules/best-practices').rules, 8 | require('@moxy/eslint-config-base/lib/rules/errors').rules, 9 | require('@moxy/eslint-config-base/lib/rules/es6').rules, 10 | require('@moxy/eslint-config-base/lib/rules/node').rules, 11 | require('@moxy/eslint-config-base/lib/rules/strict').rules, 12 | require('@moxy/eslint-config-base/lib/rules/style').rules, 13 | require('@moxy/eslint-config-base/lib/rules/variables').rules 14 | ); 15 | 16 | const rules = Object.keys(babelRules).reduce((rules, name) => { 17 | /* istanbul ignore else */ 18 | if (!babelRules[name].meta.deprecated && baseRules[name]) { 19 | rules[name] = 'off'; 20 | rules[`@babel/${name}`] = baseRules[name]; 21 | } 22 | 23 | return rules; 24 | }, {}); 25 | 26 | module.exports = { 27 | parser: '@babel/eslint-parser', 28 | plugins: ['@babel/eslint-plugin'], 29 | rules, 30 | }; 31 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/samples/my-component/MyComponent.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | import React, { PureComponent } from 'react'; 4 | import PropTypes from 'prop-types'; 5 | 6 | class MyComponent extends PureComponent { 7 | static foo = {}; 8 | 9 | static propTypes = { 10 | message: PropTypes.string, 11 | }; 12 | 13 | static defaultProps = { 14 | message: 'Welcome!', 15 | }; 16 | 17 | bar = {}; 18 | state = {}; 19 | 20 | componentDidMount() { 21 | this.setState({ name: 'André' }); 22 | } 23 | 24 | render() { 25 | return ( 26 | 27 | Hello { this.state.name } 28 | 29 | 30 | { this.props.message } 31 | 32 | ); 33 | } 34 | 35 | storeRef = (ref) => { 36 | this.ref = ref; 37 | }; 38 | 39 | handleClick = () => { 40 | this.setState({ name: 'Cruz' }); 41 | }; 42 | } 43 | 44 | export default MyComponent; 45 | -------------------------------------------------------------------------------- /packages/eslint-config-babel/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@moxy/eslint-config-babel", 3 | "description": "MOXY's ESLint configuration enhancer for projects that use Babel", 4 | "version": "13.1.0", 5 | "keywords": [ 6 | "eslint-config", 7 | "eslintconfig", 8 | "eslint", 9 | "lint", 10 | "linter", 11 | "style", 12 | "babel", 13 | "babel-eslint" 14 | ], 15 | "author": "André Cruz ", 16 | "homepage": "https://github.com/moxystudio/eslint-config", 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:moxystudio/eslint-config.git" 20 | }, 21 | "license": "MIT", 22 | "main": "lib/index.js", 23 | "files": [ 24 | "lib" 25 | ], 26 | "dependencies": { 27 | "@babel/eslint-parser": "^7.11.0", 28 | "@babel/eslint-plugin": "^7.11.0" 29 | }, 30 | "peerDependencies": { 31 | "eslint": "^7.6.0" 32 | }, 33 | "devDependencies": { 34 | "@moxy/babel-preset": "^3.2.4", 35 | "@moxy/eslint-config-base": "^13.1.0" 36 | }, 37 | "engines": { 38 | "node": ">=10", 39 | "npm": ">=3" 40 | }, 41 | "publishConfig": { 42 | "access": "public" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/samples/my-component/MyComponent.old.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | import React, { PureComponent } from 'react'; 4 | import PropTypes from 'prop-types'; 5 | 6 | class MyComponent extends PureComponent { 7 | constructor() { 8 | super(); 9 | this.state = {}; 10 | this.handleClick = this.handleClick.bind(this); 11 | this.storeRef = this.storeRef.bind(this); 12 | } 13 | 14 | componentDidMount() { 15 | this.setState({ name: 'André' }); 16 | } 17 | 18 | render() { 19 | return ( 20 | 21 | Hello { this.state.name } 22 | 23 | 24 | { this.props.message } 25 | 26 | ); 27 | } 28 | 29 | storeRef(ref) { 30 | this.ref = ref; 31 | } 32 | 33 | handleClick() { 34 | this.setState({ name: 'Cruz' }); 35 | } 36 | } 37 | 38 | MyComponent.propTypes = { 39 | message: PropTypes.string.isRequired, 40 | }; 41 | 42 | export default MyComponent; 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 Made With MOXY Lda 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/lib/rules/platforms/rn-059/any.js: -------------------------------------------------------------------------------- 1 | // React Native A11y plugin - https://github.com/FormidableLabs/eslint-plugin-react-native-a11y 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Enforce accessibilityStates property value is valid 8 | // Removed from React Native v0.60+: https://reactnative.dev/docs/0.60/view#accessibilitystates 9 | 'react-native-a11y/has-valid-accessibility-states': 'error', 10 | // Enforce accessibilityHint is used in conjunction with accessibilityLabel 11 | 'react-native-a11y/has-accessibility-hint': 'error', 12 | // Enforce that components only have either the accessibilityRole prop or 13 | // both accessibilityTraits and accessibilityComponentType props set 14 | 'react-native-a11y/has-accessibility-props': 'error', 15 | // Enforce accessibilityRole property value is valid 16 | 'react-native-a11y/has-valid-accessibility-role': 'error', 17 | // Enforce if a view has accessible={true}, that there are no touchable elements inside 18 | 'react-native-a11y/no-nested-touchables': 'error', 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-async-computed-properties.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 42 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@moxy/eslint-config-vue", 3 | "description": "MOXY's ESLint configuration enhancer for projects that use Vue", 4 | "version": "13.1.0", 5 | "keywords": [ 6 | "eslint-config", 7 | "eslintconfig", 8 | "eslint", 9 | "lint", 10 | "linter", 11 | "style", 12 | "vue-lint", 13 | "vue-eslint" 14 | ], 15 | "author": "André Cruz ", 16 | "homepage": "https://github.com/moxystudio/eslint-config", 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:moxystudio/eslint-config.git" 20 | }, 21 | "license": "MIT", 22 | "main": "lib/index.js", 23 | "files": [ 24 | "lib" 25 | ], 26 | "dependencies": { 27 | "@vue/eslint-config-prettier": "^6.0.0", 28 | "eslint-plugin-prettier": "^3.1.4", 29 | "eslint-plugin-vue": "^7.0.0-beta.1", 30 | "prettier": "^2.0.0" 31 | }, 32 | "peerDependencies": { 33 | "eslint": "^7.6.0" 34 | }, 35 | "devDependencies": { 36 | "@moxy/eslint-config-base": "^13.1.0" 37 | }, 38 | "engines": { 39 | "node": ">=10", 40 | "npm": ">=3" 41 | }, 42 | "publishConfig": { 43 | "access": "public" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/eslint-config-react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@moxy/eslint-config-react", 3 | "description": "MOXY's ESLint configuration enhancer for projects that use React", 4 | "version": "13.1.0", 5 | "keywords": [ 6 | "eslint-config", 7 | "eslintconfig", 8 | "eslint", 9 | "lint", 10 | "linter", 11 | "style", 12 | "react-lint", 13 | "react-eslint" 14 | ], 15 | "author": "André Cruz ", 16 | "homepage": "https://github.com/moxystudio/eslint-config", 17 | "repository": { 18 | "type": "git", 19 | "url": "git@github.com:moxystudio/eslint-config.git" 20 | }, 21 | "license": "MIT", 22 | "main": "lib/index.js", 23 | "files": [ 24 | "lib" 25 | ], 26 | "dependencies": { 27 | "@moxy/eslint-config-base": "^13.1.0", 28 | "eslint-plugin-react": "^7.20.5", 29 | "eslint-plugin-react-hooks": "^4.0.8" 30 | }, 31 | "peerDependencies": { 32 | "eslint": "^7.6.0" 33 | }, 34 | "devDependencies": { 35 | "@moxy/babel-preset": "^3.2.4", 36 | "@moxy/eslint-config-babel": "^13.1.0", 37 | "create-react-class": "^15.6.3", 38 | "prop-types": "^15.6.2", 39 | "react": "^16.12.0" 40 | }, 41 | "engines": { 42 | "node": ">=10", 43 | "npm": ">=3" 44 | }, 45 | "publishConfig": { 46 | "access": "public" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/eslint-config-react-web-a11y/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@moxy/eslint-config-react-web-a11y", 3 | "description": "MOXY's ESLint accessibility rules for web projects that use React", 4 | "version": "13.1.0", 5 | "keywords": [ 6 | "eslint-config", 7 | "eslintconfig", 8 | "eslint", 9 | "lint", 10 | "linter", 11 | "style", 12 | "react-lint", 13 | "react-eslint", 14 | "accessibility", 15 | "a11y", 16 | "jsx-a11y" 17 | ], 18 | "author": "André Cruz ", 19 | "homepage": "https://github.com/moxystudio/eslint-config", 20 | "repository": { 21 | "type": "git", 22 | "url": "git@github.com:moxystudio/eslint-config.git" 23 | }, 24 | "license": "MIT", 25 | "main": "lib/index.js", 26 | "files": [ 27 | "lib" 28 | ], 29 | "dependencies": { 30 | "eslint-plugin-jsx-a11y": "^6.3.1" 31 | }, 32 | "peerDependencies": { 33 | "eslint": "^7.6.0" 34 | }, 35 | "devDependencies": { 36 | "@moxy/babel-preset": "^3.2.4", 37 | "@moxy/eslint-config-babel": "^13.1.0", 38 | "@moxy/eslint-config-base": "^13.1.0", 39 | "@moxy/eslint-config-react": "^13.1.0", 40 | "react": "^16.12.0" 41 | }, 42 | "engines": { 43 | "node": ">=10", 44 | "npm": ">=3" 45 | }, 46 | "publishConfig": { 47 | "access": "public" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@moxy/eslint-config-react-native", 3 | "description": "MOXY's ESLint configuration enhancer for React Native apps", 4 | "version": "13.1.0", 5 | "keywords": [ 6 | "eslint-config", 7 | "eslintconfig", 8 | "eslint", 9 | "lint", 10 | "linter", 11 | "style", 12 | "react-lint", 13 | "react-eslint", 14 | "react-native" 15 | ], 16 | "author": "André Costa Lima ", 17 | "homepage": "https://github.com/moxystudio/eslint-config", 18 | "repository": { 19 | "type": "git", 20 | "url": "git@github.com:moxystudio/eslint-config.git" 21 | }, 22 | "license": "MIT", 23 | "main": "lib/index.js", 24 | "files": [ 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "@moxy/eslint-config-base": "^13.1.0", 29 | "eslint-import-resolver-react-native": "^0.2.0", 30 | "eslint-plugin-react-native": "^3.8.1" 31 | }, 32 | "peerDependencies": { 33 | "eslint": "^7.6.0" 34 | }, 35 | "devDependencies": { 36 | "@moxy/babel-preset": "^3.2.4", 37 | "@moxy/eslint-config-babel": "^13.1.0", 38 | "@moxy/eslint-config-react": "^13.1.0", 39 | "react": "^16.12.0", 40 | "react-native": "^0.61.5" 41 | }, 42 | "engines": { 43 | "node": ">=10", 44 | "npm": ">=3" 45 | }, 46 | "publishConfig": { 47 | "access": "public" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/lib/rules/react-native.js: -------------------------------------------------------------------------------- 1 | // React Native plugin - https://github.com/Intellicode/eslint-plugin-react-native 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Detect unused StyleSheet rules in React components 8 | // Issues: 9 | // - https://github.com/Intellicode/eslint-plugin-react-native/issues/165 10 | // - https://github.com/Intellicode/eslint-plugin-react-native/issues/241 11 | // - https://github.com/Intellicode/eslint-plugin-react-native/issues/258 12 | 'react-native/no-unused-styles': 'error', 13 | // Require StyleSheet keys to be sorted 14 | 'react-native/sort-styles': ['error', 'asc'], 15 | // Enforce using platform specific filenames when necessary 16 | 'react-native/split-platform-components': 'error', 17 | // Detect inline styles in components 18 | 'react-native/no-inline-styles': 'error', 19 | // Detect color literals in styles 20 | 'react-native/no-color-literals': 'error', 21 | // Detect raw text outside of Text component 22 | // Issues: 23 | // - https://github.com/Intellicode/eslint-plugin-react-native/issues/225 24 | 'react-native/no-raw-text': 'error', 25 | // No Single Element Style Arrays are allowed 26 | 'react-native/no-single-element-style-arrays': 'error', 27 | }, 28 | }; 29 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/rules/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parserOptions": { 4 | "ecmaFeatures": { 5 | "jsx": true 6 | } 7 | }, 8 | "overrides": [ 9 | { 10 | "files": "./**/*.js", 11 | "excludedFiles": [ 12 | "./variables-no-unused.js", 13 | "./es6-esm", 14 | "./node" 15 | ], 16 | "env": { 17 | "browser": true 18 | }, 19 | "extends": "../..", 20 | "rules": { 21 | "no-unused-vars": "off" 22 | } 23 | }, 24 | { 25 | "files": "./variables-no-unused.js", 26 | "extends": "../..", 27 | "env": { 28 | "browser": true 29 | } 30 | }, 31 | { 32 | "files": "./node.js", 33 | "extends": "../..", 34 | "env": { 35 | "node": true 36 | }, 37 | "rules": { 38 | "no-unused-vars": "off" 39 | } 40 | }, 41 | { 42 | "files": "./es6-esm.js", 43 | "extends": "../../esm", 44 | "env": { 45 | "browser": true 46 | }, 47 | "rules": { 48 | "no-unused-vars": "off" 49 | } 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-no-unused-components.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 31 | 32 | 33 | 39 | 40 | 51 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@moxy/eslint-config-react-native-a11y", 3 | "description": "MOXY's ESLint accessibility rules for React Native apps", 4 | "version": "13.1.0", 5 | "keywords": [ 6 | "eslint-config", 7 | "eslintconfig", 8 | "eslint", 9 | "lint", 10 | "linter", 11 | "style", 12 | "react-lint", 13 | "react-eslint", 14 | "react-native", 15 | "a11y", 16 | "accessibility" 17 | ], 18 | "author": "André Costa Lima ", 19 | "homepage": "https://github.com/moxystudio/eslint-config", 20 | "repository": { 21 | "type": "git", 22 | "url": "git@github.com:moxystudio/eslint-config.git" 23 | }, 24 | "license": "MIT", 25 | "main": "index.js", 26 | "files": [ 27 | "lib", 28 | "rn-*", 29 | "android.js", 30 | "ios.js" 31 | ], 32 | "dependencies": { 33 | "@moxy/eslint-config-base": "^13.1.0", 34 | "eslint-plugin-react-native-a11y": "^2.0.0" 35 | }, 36 | "peerDependencies": { 37 | "eslint": "^7.6.0" 38 | }, 39 | "devDependencies": { 40 | "@moxy/babel-preset": "^3.2.4", 41 | "@moxy/eslint-config-babel": "^13.1.0", 42 | "@moxy/eslint-config-react": "^13.1.0", 43 | "react": "^16.12.0", 44 | "react-native": "^0.62.0" 45 | }, 46 | "engines": { 47 | "node": ">=10", 48 | "npm": ">=3" 49 | }, 50 | "publishConfig": { 51 | "access": "public" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/rules/variables.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // `no-shadow-restricted-names` - disallow identifiers from shadowing restricted names 4 | // --------------------------------------------------------------------- 5 | // Bad 6 | { 7 | const undefined = () => {}; 8 | } 9 | 10 | // `no-undef` - disallow the use of undeclared variables unless mentioned in /*global */ comments 11 | // --------------------------------------------------------------------- 12 | // Bad 13 | { 14 | const x = y + 1; 15 | } 16 | 17 | // `no-undef-init` - disallow initializing variables to undefined 18 | // --------------------------------------------------------------------- 19 | // Bad 20 | { 21 | let x = undefined; 22 | 23 | x = 1; 24 | } 25 | 26 | // `no-unused-vars` - disallow unused variables 27 | // --------------------------------------------------------------------- 28 | // See file ./variables-no-unused.js 29 | 30 | // `no-use-before-define` - disallow the use of variables before they are defined 31 | // --------------------------------------------------------------------- 32 | // Bad (variables) 33 | { 34 | const bar = a; 35 | const a = 10; 36 | } 37 | // Good (variables) 38 | { 39 | const a = 10; 40 | const bar = a; 41 | } 42 | // Bad (classes) 43 | { 44 | const f = new Person(); 45 | 46 | class Person {} 47 | } 48 | // Good (classes) 49 | { 50 | class Person {} 51 | 52 | const f = new Person(); 53 | } 54 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | This repository follows a _monorepo_ structure, for which we use [lerna](https://lerna.js.org) to manage versions of changed packages, as well as the release and publishing process. 4 | 5 | To learn more about what commands are available for lerna, how it works and how it can be configured, please check out [lerna's repository](https://github.com/lerna/lerna/). 6 | 7 | It's relevant to note, though, that the main workflow using lerna has already been setup as _npm-scripts_, which means that you should not need to use lerna commands while contributing. 8 | 9 | ## Tests 10 | 11 | In order to test all packages, you simply need to run the following command: 12 | 13 | ```sh 14 | $ npm run test 15 | ``` 16 | 17 | ## Release and publish 18 | 19 | To release and publish the packages in which changes have been made, run: 20 | 21 | ```sh 22 | $ npm run release 23 | ``` 24 | 25 | ❗️ **IMPORTANT** : do not try to release a single package from that package's root directory. _Lerna_ takes care of figuring out which packages have suffered changes and only releases and publishes the updated packages. Please use the release scripts provided in the repository's root `package.json`. 26 | 27 | We are using _lerna_ in fixed version mode, which means that when multiple packages are changed between releases, they will all be updated to the same version. We also use [_conventional-commits_](https://www.conventionalcommits.org), which means the subject of the commit messages will decide the version bump that will occur. 28 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/test/rules/vue-require-valid-default-prop.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 54 | -------------------------------------------------------------------------------- /packages/eslint-config-vue/README.md: -------------------------------------------------------------------------------- 1 | # eslint-config-vue 2 | 3 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] 4 | [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] 5 | 6 | [npm-url]:https://npmjs.org/package/@moxy/eslint-config-vue 7 | [npm-image]:https://img.shields.io/npm/v/@moxy/eslint-config-vue.svg 8 | [downloads-image]:https://img.shields.io/npm/dm/@moxy/eslint-config-vue.svg 9 | [david-dm-url]:https://david-dm.org/moxystudio/eslint-config?path=packages/eslint-config-vue 10 | [david-dm-image]:https://img.shields.io/david/moxystudio/eslint-config.svg?path=packages/eslint-config-vue 11 | [david-dm-dev-url]:https://david-dm.org/moxystudio/eslint-config?type=dev&path=packages/eslint-config-vue 12 | [david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/eslint-config.svg?path=packages/eslint-config-vue 13 | 14 | MOXY's [ESLint](http://eslint.org/) configuration **enhancer** for projects that use [Vue](https://vuejs.org). 15 | 16 | ## Installation 17 | 18 | ```sh 19 | $ npm install --save-dev eslint @moxy/eslint-config-vue 20 | ``` 21 | 22 | ## Usage 23 | 24 | Create a `.eslintrc.json` file in the project root and extend `@moxy/eslint-config-vue`. 25 | 26 | This package should be used in conjunction with [`@moxy/eslint-config-base`](../eslint-config-base). 27 | 28 | ### Example 29 | 30 | ```json 31 | { 32 | "root": true, 33 | "env": { 34 | "browser": true 35 | }, 36 | "extends": [ 37 | "@moxy/eslint-config-base/esm", 38 | "@moxy/eslint-config-vue" 39 | ] 40 | } 41 | ``` 42 | -------------------------------------------------------------------------------- /packages/eslint-config-react/README.md: -------------------------------------------------------------------------------- 1 | # eslint-config-react 2 | 3 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] 4 | [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] 5 | 6 | [npm-url]:https://npmjs.org/package/@moxy/eslint-config-react 7 | [npm-image]:https://img.shields.io/npm/v/@moxy/eslint-config-react.svg 8 | [downloads-image]:https://img.shields.io/npm/dm/@moxy/eslint-config-react.svg 9 | [david-dm-url]:https://david-dm.org/moxystudio/eslint-config?path=packages/eslint-config-react 10 | [david-dm-image]:https://img.shields.io/david/moxystudio/eslint-config.svg?path=packages/eslint-config-react 11 | [david-dm-dev-url]:https://david-dm.org/moxystudio/eslint-config?type=dev&path=packages/eslint-config-react 12 | [david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/eslint-config.svg?path=packages/eslint-config-react 13 | 14 | MOXY's [ESLint](http://eslint.org/) configuration **enhancer** for projects that use [React](https://reactjs.org). 15 | 16 | ## Installation 17 | 18 | ```sh 19 | $ npm install --save-dev eslint @moxy/eslint-config-react 20 | ``` 21 | 22 | ## Usage 23 | 24 | Create a `.eslintrc.json` file in the project root and extend `@moxy/eslint-config-react`. 25 | 26 | This package should be used in conjunction with [`@moxy/eslint-config-base`](../eslint-config-base). 27 | 28 | ### Example 29 | 30 | ```json 31 | { 32 | "root": true, 33 | "env": { 34 | "browser": true 35 | }, 36 | "extends": [ 37 | "@moxy/eslint-config-base/esm", 38 | "@moxy/eslint-config-react" 39 | ] 40 | } 41 | ``` 42 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/README.md: -------------------------------------------------------------------------------- 1 | # eslint-config-react-native 2 | 3 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] 4 | [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] 5 | 6 | [npm-url]:https://npmjs.org/package/@moxy/eslint-config-react-native 7 | [npm-image]:https://img.shields.io/npm/v/@moxy/eslint-config-react-native.svg 8 | [downloads-image]:https://img.shields.io/npm/dm/@moxy/eslint-config-react-native.svg 9 | [david-dm-url]:https://david-dm.org/moxystudio/eslint-config?path=packages/eslint-config-react-native 10 | [david-dm-image]:https://img.shields.io/david/moxystudio/eslint-config.svg?path=packages/eslint-config-react-native 11 | [david-dm-dev-url]:https://david-dm.org/moxystudio/eslint-config?type=dev&path=packages/eslint-config-react-native 12 | [david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/eslint-config.svg?path=packages/eslint-config-react-native 13 | 14 | MOXY's [ESLint](http://eslint.org/) configuration **enhancer** for [React Native](https://reactnative.dev/) apps. 15 | 16 | ## Installation 17 | 18 | ```sh 19 | $ npm install --save-dev eslint @moxy/eslint-config-react-native 20 | ``` 21 | 22 | ## Usage 23 | 24 | Create a `.eslintrc.json` file in the project root and extend `@moxy/eslint-config-react-native`. 25 | 26 | This package should be used in conjunction with [`@moxy/eslint-config-base`](../eslint-config-base). 27 | 28 | ### Example 29 | 30 | ```json 31 | { 32 | "root": true, 33 | "extends": [ 34 | "@moxy/eslint-config-base/esm", 35 | "@moxy/eslint-config-react-native" 36 | ] 37 | } 38 | ``` 39 | 40 | ℹ️ The environment is automatically set to `react-native/react-native`. 41 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/README.md: -------------------------------------------------------------------------------- 1 | # eslint-config-jest 2 | 3 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] 4 | [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] 5 | 6 | 7 | [npm-url]:https://npmjs.org/package/@moxy/eslint-config-jest 8 | [npm-image]:https://img.shields.io/npm/v/@moxy/eslint-config-jest.svg 9 | [downloads-image]:https://img.shields.io/npm/dm/@moxy/eslint-config-jest.svg 10 | [david-dm-url]:https://david-dm.org/moxystudio/eslint-config?path=packages/eslint-config-jest 11 | [david-dm-image]:https://img.shields.io/david/moxystudio/eslint-config.svg?path=packages/eslint-config-jest 12 | [david-dm-dev-url]:https://david-dm.org/moxystudio/eslint-config?type=dev&path=packages/eslint-config-jest 13 | [david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/eslint-config.svg?path=packages/eslint-config-jest 14 | 15 | MOXY's [ESLint](http://eslint.org/) configuration **enhancer** for projects that use [Jest](https://jestjs.io) for testing. 16 | 17 | ## Installation 18 | 19 | ```sh 20 | $ npm install --save-dev eslint @moxy/eslint-config-jest 21 | ``` 22 | 23 | ## Usage 24 | 25 | Create a `.eslintrc.json` file in the project root and extend `@moxy/eslint-config-jest`. 26 | 27 | This package should be used in conjunction with [`@moxy/eslint-config-base`](../eslint-config-base). 28 | 29 | ℹ️ Only test files will have Jest globals and rules activated. Please check the [test-patterns](../eslint-config-base/lib/test-patterns.js) to see how you should name your test files. 30 | 31 | ### Example 32 | 33 | ```json 34 | { 35 | "root": true, 36 | "env": { 37 | "browser": true 38 | }, 39 | "extends": [ 40 | "@moxy/eslint-config-base/esm", 41 | "@moxy/eslint-config-jest" 42 | ] 43 | } 44 | ``` 45 | -------------------------------------------------------------------------------- /packages/eslint-config-react-web-a11y/README.md: -------------------------------------------------------------------------------- 1 | # eslint-config-react-web-a11y 2 | 3 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] 4 | [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] 5 | 6 | [npm-url]:https://npmjs.org/package/@moxy/eslint-config-react-web-a11y 7 | [npm-image]:https://img.shields.io/npm/v/@moxy/eslint-config-react-web-a11y.svg 8 | [downloads-image]:https://img.shields.io/npm/dm/@moxy/eslint-config-react-web-a11y.svg 9 | [david-dm-url]:https://david-dm.org/moxystudio/eslint-config?path=packages/eslint-config-react-web-a11y 10 | [david-dm-image]:https://img.shields.io/david/moxystudio/eslint-config.svg?path=packages/eslint-config-react-web-a11y 11 | [david-dm-dev-url]:https://david-dm.org/moxystudio/eslint-config?type=dev&path=packages/eslint-config-react-web-a11y 12 | [david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/eslint-config.svg?path=packages/eslint-config-react-web-a11y 13 | 14 | MOXY's [ESLint](http://eslint.org/) accessibility rules for web projects that use [React](https://reactjs.org). 15 | 16 | ## Installation 17 | 18 | ```sh 19 | $ npm install --save-dev eslint @moxy/eslint-config-react-web-a11y 20 | ``` 21 | 22 | ## Usage 23 | 24 | Create a `.eslintrc.json` file in the project root and extend `@moxy/eslint-config-react-web-a11y`. 25 | 26 | This package should be used in conjunction with [`@moxy/eslint-config-base`](../eslint-config-base) and [`@moxy/eslint-config-react`](../eslint-config-react). 27 | 28 | ### Example 29 | 30 | ```json 31 | { 32 | "root": true, 33 | "env": { 34 | "browser": true 35 | }, 36 | "extends": [ 37 | "@moxy/eslint-config-base/esm", 38 | "@moxy/eslint-config-react", 39 | "@moxy/eslint-config-react-web-a11y" 40 | ] 41 | } 42 | ``` 43 | -------------------------------------------------------------------------------- /MIGRATION.md: -------------------------------------------------------------------------------- 1 | # Migration guide 2 | 3 | The previous package that existed in this repository, `@moxy/eslint-config`, has been deprecated. To learn how to migrate into the new configuration structure, read below. 4 | 5 | ## Migrating from <= 10 6 | 7 | Until now, in order to use MOXY's eslint configuration, you would have to import the `@moxy/eslint-config` package and extend your project's eslint configuration with a **base** configuration (`es5`, `es6`, `es7`, ...) and the **addons** you wished to use (`browser`, `node`, `react`, ...). 8 | 9 | Your `.eslintrc.json` would look similar to this: 10 | 11 | ```json 12 | { 13 | "root": true, 14 | "extends": [ 15 | "@moxy/eslint-config/es9", 16 | "@moxy/eslint-config/addons/browser", 17 | "@moxy/eslint-config/addons/babel-parser", 18 | "@moxy/eslint-config/addons/es-modules", 19 | "@moxy/eslint-config/addons/react" 20 | ] 21 | } 22 | ``` 23 | 24 | This monolithic, multiple **addon** approach has been refactored into one **base** configuration package and several **enhancer** packages (more info on what packages exist and how to use them is in this repository's [README](README.md)). 25 | 26 | For example, the example given above would look like this after migrating to the newest version: 27 | 28 | ```json 29 | { 30 | "root": true, 31 | "env": { 32 | "browser": true, 33 | }, 34 | "extends": [ 35 | "@moxy/eslint-config-base/esm/es2018", 36 | "@moxy/eslint-config-babel", 37 | "@moxy/eslint-config-react" 38 | ] 39 | } 40 | ``` 41 | 42 | ...where: 43 | 44 | - `@moxy/eslint-config/es9`and `@moxy/eslint-config/addons/es-modules` was replaced with `@moxy/eslint-config-base/esm/es2018` 45 | - `@moxy/eslint-config/addons/browser` was replaced with ESLint's [`env`](https://eslint.org/docs/user-guide/configuring#specifying-environments). 46 | - `@moxy/eslint-config/addons/babel-parser` was replaced with `@moxy/eslint-config-babel` 47 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/rules/jsdoc.js: -------------------------------------------------------------------------------- 1 | // JSDoc rules - https://github.com/gajus/eslint-plugin-jsdoc 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Ensures that parameter names in JSDoc match those in the function declaration 8 | 'jsdoc/check-param-names': 'error', 9 | // Reports invalid block tag names 10 | 'jsdoc/check-tag-names': 'error', 11 | // Reports invalid types 12 | 'jsdoc/check-types': 'error', 13 | // Enforces a consistent padding of the block description 14 | 'jsdoc/newline-after-description': 'error', 15 | // Requires that block description and tag description are written in complete sentences 16 | 'jsdoc/require-description-complete-sentence': 'error', 17 | // Requires a hyphen before the @param description 18 | 'jsdoc/require-hyphen-before-param-description': 'error', 19 | // Requires that all function parameters are documented 20 | 'jsdoc/require-param': 'error', 21 | // Requires that all function parameters have name. 22 | 'jsdoc/require-param-name': 'error', 23 | // Requires that @param tag has description value 24 | 'jsdoc/require-param-description': 'error', 25 | // Requires that @param tag has type value 26 | 'jsdoc/require-param-type': 'error', 27 | // Requires @return if the function returns a value 28 | 'jsdoc/require-returns': 'error', 29 | // Requires that @returns tag has description value 30 | 'jsdoc/require-returns-description': 'warn', 31 | // Requires that @returns tag has type value 32 | 'jsdoc/require-returns-type': 'error', 33 | // Checks if the return expression exists in function body and in the comment. 34 | 'jsdoc/require-returns-check': 'error', 35 | // Requires all types to be valid JSDoc or Closure compiler types without syntax errors 36 | 'jsdoc/valid-types': 'error', 37 | }, 38 | }; 39 | -------------------------------------------------------------------------------- /packages/eslint-config-jest/test/rules/jest.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // `no-disabled-tests` - Disallow disabled tests 4 | // --------------------------------------------------------------------- 5 | // Not advisable 6 | it.skip('no-disabled-tests bad', () => {}); 7 | // Good 8 | it('no-disabled-tests good', () => {}); 9 | 10 | // `no-focused-tests` - Disallow focused tests 11 | // --------------------------------------------------------------------- 12 | // Bad 13 | it.only('no-focused-tests bad', () => {}); 14 | // Good 15 | it('no-focused-tests good', () => {}); 16 | 17 | // `no-identical-title` - Disallow identical titles 18 | // --------------------------------------------------------------------- 19 | // Bad 20 | it('no-identical-title bad', () => {}); 21 | it('no-identical-title bad', () => {}); 22 | // Good 23 | it('no-identical-title good', () => {}); 24 | it('no-identical-title good 2', () => {}); 25 | 26 | // `prefer-to-have-length` - prefer toHaveLength() over toBe() 27 | // --------------------------------------------------------------------- 28 | // Bad 29 | it('prefer-to-have-length bad', () => { 30 | expect([].length).toBe(0); 31 | }); 32 | // Good 33 | it('prefer-to-have-length good', () => { 34 | expect([].length).toHaveLength(0); 35 | }); 36 | 37 | // `valid-expect` - enforce valid expect() usage 38 | // --------------------------------------------------------------------- 39 | // Bad 40 | it('valid-expect bad', () => { 41 | expect('something'); 42 | }); 43 | // Good 44 | it('valid-expect good', () => { 45 | expect('something').not.toEqual('else'); 46 | }); 47 | 48 | // `lowercase-name` - Enforce lowercase test names 49 | // --------------------------------------------------------------------- 50 | // Bad 51 | it('Lowercase-name bad', () => {}); 52 | // Also bad 53 | describe('Foo', () => { 54 | describe('Foo', () => { 55 | 56 | }); 57 | }); 58 | // Good 59 | it('lowercase-name good', () => {}); 60 | // Also good 61 | describe('Foo', () => { 62 | describe('myMethod', () => { 63 | 64 | }); 65 | }); 66 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [13.1.0](https://github.com/moxystudio/eslint-config/compare/v13.0.3...v13.1.0) (2021-07-13) 7 | 8 | 9 | ### Features 10 | 11 | * allow noopener in rel when using target blank ([#111](https://github.com/moxystudio/eslint-config/issues/111)) ([6a26997](https://github.com/moxystudio/eslint-config/commit/6a2699739761cc8deb7120370adebf4f07a0f048)) 12 | 13 | 14 | 15 | ### [13.0.3](https://github.com/moxystudio/eslint-config/compare/v13.0.2...v13.0.3) (2020-09-05) 16 | 17 | **Note:** Version bump only for package @moxy/eslint-config-react-native-a11y 18 | 19 | 20 | 21 | 22 | 23 | ### [13.0.2](https://github.com/moxystudio/eslint-config/compare/v13.0.1...v13.0.2) (2020-09-05) 24 | 25 | **Note:** Version bump only for package @moxy/eslint-config-react-native-a11y 26 | 27 | 28 | 29 | 30 | 31 | ## [13.0.0](https://github.com/moxystudio/eslint-config/compare/v12.3.1...v13.0.0) (2020-08-07) 32 | 33 | 34 | ### ⚠ BREAKING CHANGES 35 | 36 | * all packages have now a peerDependency on eslint v7 37 | 38 | ### Features 39 | 40 | * upgrade to eslint v7! ([#108](https://github.com/moxystudio/eslint-config/issues/108)) ([16ba3a3](https://github.com/moxystudio/eslint-config/commit/16ba3a37c7e91c1ce6e4e7dd313c0c3cd9484ab2)) 41 | 42 | 43 | 44 | ### [12.3.1](https://github.com/moxystudio/eslint-config/compare/v12.3.0...v12.3.1) (2020-07-01) 45 | 46 | 47 | ### Bug Fixes 48 | 49 | * disable rules that are cumbersome in tests ([d374541](https://github.com/moxystudio/eslint-config/commit/d3745418bd3500665e5096d436214e4504e9e0d7)) 50 | 51 | 52 | 53 | ## [12.3.0](https://github.com/moxystudio/eslint-config/compare/v12.2.0...v12.3.0) (2020-07-01) 54 | 55 | 56 | ### Features 57 | 58 | * add react native a11y enhancer ([7734e2e](https://github.com/moxystudio/eslint-config/commit/7734e2e983e41928bb5f827cec2d982adbb143fb)) 59 | -------------------------------------------------------------------------------- /packages/eslint-config-babel/README.md: -------------------------------------------------------------------------------- 1 | # eslint-config-babel 2 | 3 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] 4 | [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] 5 | 6 | [npm-url]:https://npmjs.org/package/@moxy/eslint-config-react 7 | [npm-image]:https://img.shields.io/npm/v/@moxy/eslint-config-react.svg 8 | [downloads-image]:https://img.shields.io/npm/dm/@moxy/eslint-config-react.svg 9 | [david-dm-url]:https://david-dm.org/moxystudio/eslint-config?path=packages/eslint-config-react 10 | [david-dm-image]:https://img.shields.io/david/moxystudio/eslint-config.svg?path=packages/eslint-config-react 11 | [david-dm-dev-url]:https://david-dm.org/moxystudio/eslint-config?type=dev&path=packages/eslint-config-react 12 | [david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/eslint-config.svg?path=packages/eslint-config-react 13 | 14 | MOXY's [ESLint](http://eslint.org/) configuration **enhancer** for projects that use [Babel](https://babeljs.io/). 15 | 16 | ## Installation 17 | 18 | ```sh 19 | $ npm install --save-dev eslint @moxy/eslint-config-babel 20 | ``` 21 | 22 | ## Usage 23 | 24 | Create a `.eslintrc.json` file in the project root and extend `@moxy/eslint-config-babel`. 25 | 26 | This package should be used in conjunction with [`@moxy/eslint-config-base`](../eslint-config-base). 27 | 28 | ### Example 29 | 30 | ```json 31 | { 32 | "root": true, 33 | "env": { 34 | "browser": true, 35 | }, 36 | "extends": [ 37 | "@moxy/eslint-config-base/esm", 38 | "@moxy/eslint-config-babel" 39 | ] 40 | } 41 | ``` 42 | 43 | ⚠️ If you are using a monorepo, you will need specify the `configFile` to point to the root: 44 | 45 | ```json 46 | { 47 | "root": true, 48 | "env": { 49 | "browser": true 50 | }, 51 | "extends": [ 52 | "@moxy/eslint-config-base/esm", 53 | "@moxy/eslint-config-babel" 54 | ], 55 | "parserOptions": { 56 | "babelOptions": { 57 | "configFile": "./.babelrc.json" 58 | } 59 | } 60 | } 61 | ``` 62 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/test/rules/no-color-literals.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View, Text } from 'react-native'; 3 | 4 | // `no-color-literals` - Detect color literals in styles 5 | // -------------------------------------------------------------------- 6 | { 7 | const styles = StyleSheet.create({ 8 | text: {}, 9 | }); 10 | 11 | // Bad 12 | { 13 | const MyComponent = () => ; 14 | } 15 | 16 | // Also bad 17 | { 18 | const MyComponent = () => ; 19 | } 20 | 21 | // Also bad 22 | { 23 | const MyComponent = () => ; 24 | } 25 | 26 | // Also bad 27 | { 28 | const MyComponent = () => ; 29 | } 30 | 31 | // Also bad 32 | { 33 | const MyComponent = () => MOXY; 34 | } 35 | 36 | // Also bad 37 | { 38 | const MyComponent = () => MOXY; 39 | } 40 | 41 | // Also bad 42 | { 43 | const MyComponent = () => MOXY; 44 | } 45 | } 46 | // Also bad 47 | { 48 | const styles = StyleSheet.create({ 49 | text: { 50 | backgroundColor: 'blue', 51 | color: 'red', 52 | }, 53 | }); 54 | } 55 | // Also bad 56 | { 57 | const styles = StyleSheet.create({ 58 | text: { 59 | backgroundColor: '#000', 60 | color: '#FFF', 61 | }, 62 | }); 63 | } 64 | // Also bad 65 | { 66 | const fooColor = '#000'; 67 | const styles = StyleSheet.create({ 68 | text: { 69 | color: true ? '#FFF' : fooColor, 70 | }, 71 | }); 72 | } 73 | // Good 74 | { 75 | const fooColor = '#000'; 76 | const styles = StyleSheet.create({ 77 | text: { 78 | color: fooColor, 79 | }, 80 | }); 81 | } 82 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [13.1.0](https://github.com/moxystudio/eslint-config/compare/v13.0.3...v13.1.0) (2021-07-13) 7 | 8 | 9 | ### Features 10 | 11 | * allow noopener in rel when using target blank ([#111](https://github.com/moxystudio/eslint-config/issues/111)) ([6a26997](https://github.com/moxystudio/eslint-config/commit/6a2699739761cc8deb7120370adebf4f07a0f048)) 12 | 13 | 14 | 15 | ### [13.0.3](https://github.com/moxystudio/eslint-config/compare/v13.0.2...v13.0.3) (2020-09-05) 16 | 17 | **Note:** Version bump only for package @moxy/eslint-config-react-native 18 | 19 | 20 | 21 | 22 | 23 | ### [13.0.2](https://github.com/moxystudio/eslint-config/compare/v13.0.1...v13.0.2) (2020-09-05) 24 | 25 | **Note:** Version bump only for package @moxy/eslint-config-react-native 26 | 27 | 28 | 29 | 30 | 31 | ## [13.0.0](https://github.com/moxystudio/eslint-config/compare/v12.3.1...v13.0.0) (2020-08-07) 32 | 33 | 34 | ### ⚠ BREAKING CHANGES 35 | 36 | * all packages have now a peerDependency on eslint v7 37 | 38 | ### Features 39 | 40 | * upgrade to eslint v7! ([#108](https://github.com/moxystudio/eslint-config/issues/108)) ([16ba3a3](https://github.com/moxystudio/eslint-config/commit/16ba3a37c7e91c1ce6e4e7dd313c0c3cd9484ab2)) 41 | 42 | 43 | 44 | ### [12.3.1](https://github.com/moxystudio/eslint-config/compare/v12.3.0...v12.3.1) (2020-07-01) 45 | 46 | 47 | ### Bug Fixes 48 | 49 | * disable rules that are cumbersome in tests ([d374541](https://github.com/moxystudio/eslint-config/commit/d3745418bd3500665e5096d436214e4504e9e0d7)) 50 | 51 | 52 | 53 | ## [12.3.0](https://github.com/moxystudio/eslint-config/compare/v12.2.0...v12.3.0) (2020-07-01) 54 | 55 | 56 | ### Features 57 | 58 | * add react native a11y enhancer ([7734e2e](https://github.com/moxystudio/eslint-config/commit/7734e2e983e41928bb5f827cec2d982adbb143fb)) 59 | 60 | 61 | 62 | ## [12.2.0](https://github.com/moxystudio/eslint-config/compare/v12.1.1...v12.2.0) (2020-06-25) 63 | 64 | 65 | ### Features 66 | 67 | * add React Native enhancer ([e2253e9](https://github.com/moxystudio/eslint-config/commit/e2253e9c4ee78c41a2952d7bbfc150364e23ef19)) 68 | -------------------------------------------------------------------------------- /packages/eslint-config-react-native-a11y/README.md: -------------------------------------------------------------------------------- 1 | # eslint-config-react-native-a11y 2 | 3 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] 4 | [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] 5 | 6 | [npm-url]:https://npmjs.org/package/@moxy/eslint-config-react-native-a11y 7 | [npm-image]:https://img.shields.io/npm/v/@moxy/eslint-config-react-native-a11y.svg 8 | [downloads-image]:https://img.shields.io/npm/dm/@moxy/eslint-config-react-native-a11y.svg 9 | [david-dm-url]:https://david-dm.org/moxystudio/eslint-config?path=packages/eslint-config-react-native-a11y 10 | [david-dm-image]:https://img.shields.io/david/moxystudio/eslint-config.svg?path=packages/eslint-config-react-native-a11y 11 | [david-dm-dev-url]:https://david-dm.org/moxystudio/eslint-config?type=dev&path=packages/eslint-config-react-native-a11y 12 | [david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/eslint-config.svg?path=packages/eslint-config-react-native-a11y 13 | 14 | MOXY's [ESLint](http://eslint.org/) accessibility rules for [React Native](https://reactnative.dev/) apps. 15 | 16 | ## Installation 17 | 18 | ```sh 19 | $ npm install --save-dev eslint @moxy/eslint-config-react-native-a11y 20 | ``` 21 | 22 | ## Usage 23 | 24 | Create a `.eslintrc.json` file in the project root and extend from one of these configurations: 25 | 26 | - `@moxy/eslint-config-react-native-a11y` - for apps targeting the latest version of React Native. 27 | - `@moxy/eslint-config-react-native-a11y/rn-062` - for apps targeting React Native ~0.62.0. 28 | - `@moxy/eslint-config-react-native-a11y/rn-061` - for apps targeting React Native ~0.61.0. 29 | - `@moxy/eslint-config-react-native-a11y/rn-060` - for apps targeting React Native ~0.60.0. 30 | - `@moxy/eslint-config-react-native-a11y/rn-059` - for apps targeting React Native <=0.59.10. 31 | 32 | ℹ️ By default, the configurations above are for both iOS and Android. If you are targeting only one platform, append its name as follows: 33 | 34 | - `@moxy/eslint-config-react-native-a11y/android` 35 | - `@moxy/eslint-config-react-native-a11y/ios` 36 | - `@moxy/eslint-config-react-native-a11y/rn-*/android` 37 | - `@moxy/eslint-config-react-native-a11y/rn-*/ios` 38 | 39 | This package should be used in conjunction with: 40 | 41 | - [`@moxy/eslint-config-base`](../eslint-config-base) 42 | - [`@moxy/eslint-config-react`](../eslint-config-react) 43 | - [`@moxy/eslint-config-react-native`](../eslint-config-react-native) 44 | 45 | ### Example 46 | 47 | ```json 48 | { 49 | "root": true, 50 | "extends": [ 51 | "@moxy/eslint-config-base/esm", 52 | "@moxy/eslint-config-react", 53 | "@moxy/eslint-config-react-native", 54 | "@moxy/eslint-config-react-native-a11y" 55 | ] 56 | } 57 | ``` 58 | -------------------------------------------------------------------------------- /packages/eslint-config-base/test/samples/es2015/contrived.good.js: -------------------------------------------------------------------------------- 1 | // Made up sample.. not genuine 2 | 3 | 'use strict'; 4 | 5 | const log = () => {}; 6 | 7 | class Person { 8 | constructor(name) { 9 | this._name = name; 10 | } 11 | 12 | getName() { 13 | return this._name; 14 | } 15 | 16 | sayHello() { 17 | log(`Hello ${this._name}`); 18 | } 19 | } 20 | 21 | const person = new Person('André'); 22 | 23 | person.getName(); 24 | 25 | // ------------------------------------------------- 26 | 27 | function sumOne(x = 1) { 28 | x -= 1; 29 | x += 1; 30 | x *= 1; 31 | x /= 1; 32 | 33 | return x + 1; 34 | } 35 | 36 | sumOne(1); 37 | 38 | // ------------------------------------------------- 39 | 40 | function printArray(arr) { 41 | for (let x = 0; x <= arr.length; x += 1) { 42 | log(x); 43 | } 44 | 45 | let y; 46 | 47 | while (y < arr.length) { 48 | log(y); 49 | y += 1; 50 | } 51 | 52 | y = 0; 53 | do { 54 | log(y); 55 | y += 1; 56 | } while (y < arr.length); 57 | 58 | y = 0; 59 | do { 60 | log(y); 61 | } while ((y += 1) < arr.length); 62 | } 63 | 64 | printArray([]); 65 | 66 | // ------------------------------------------------- 67 | 68 | function returnSwitch(x) { 69 | switch (x) { 70 | case 0.1: 71 | return x; 72 | case 0.2: { 73 | const y = x + 1; 74 | 75 | return y; 76 | } 77 | default: 78 | return x; 79 | } 80 | } 81 | 82 | returnSwitch(0.3); 83 | 84 | // ------------------------------------------------- 85 | 86 | function chaining(arr) { 87 | return arr 88 | .filter(() => true) 89 | .map((x) => x + 1); 90 | } 91 | 92 | chaining([]); 93 | 94 | // ------------------------------------------------- 95 | 96 | function fnWithRestParams(...arr) { 97 | return arr 98 | .filter(() => true) 99 | .map((x) => x + 1); 100 | } 101 | 102 | fnWithRestParams(1, 2); 103 | 104 | // ------------------------------------------------- 105 | 106 | function fnWithDefaultArgs(x = 1) { 107 | return x + 1; 108 | } 109 | 110 | fnWithDefaultArgs(); 111 | 112 | // ------------------------------------------------- 113 | 114 | function fnThatUsesSpread() { 115 | const [first, ...other] = [1, 2, 3]; 116 | 117 | log(first, other); 118 | } 119 | 120 | fnThatUsesSpread(); 121 | 122 | // ------------------------------------------------- 123 | 124 | function fnThatUsesEnhancedObjectProperties(x) { 125 | return { 126 | [`prop-${x}`]: true, 127 | x, 128 | }; 129 | } 130 | 131 | fnThatUsesEnhancedObjectProperties(); 132 | 133 | // -------------------------------------------------- 134 | 135 | function pow(x) { 136 | return Math.pow(x, 2); 137 | } 138 | 139 | pow(); 140 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/rules/errors.js: -------------------------------------------------------------------------------- 1 | // Possible errors - ttp://eslint.org/docs/rules/#possible-errors 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Disallow await inside of loops 8 | 'no-await-in-loop': 'warn', 9 | // Disallow comparing against -0 10 | 'no-compare-neg-zero': 'error', 11 | // Disallow assignment operators in conditional expressions 12 | 'no-cond-assign': ['error', 'except-parens'], 13 | // Disallow constant expressions in conditions 14 | 'no-constant-condition': 'error', 15 | // Disallow control characters in regular expressions 16 | 'no-control-regex': 'error', 17 | // Disallow the use of debugger 18 | // comment: just a warning by default, the build process should remove debugger statements 19 | 'no-debugger': 'warn', 20 | // Disallow duplicate keys in object literals 21 | 'no-dupe-keys': 'error', 22 | // Disallow a duplicate case labels 23 | 'no-duplicate-case': 'error', 24 | // Disallow empty block statements 25 | 'no-empty': 'error', 26 | // Disallow the use of empty character classes in regular expressions 27 | 'no-empty-character-class': 'error', 28 | // Disallow unnecessary boolean casts 29 | 'no-extra-boolean-cast': 'error', 30 | // Disallow unnecessary parentheses 31 | 'no-extra-parens': ['error', 'functions'], 32 | // Disallow unnecessary semicolons 33 | 'no-extra-semi': 'error', 34 | // Disallow reassigning function declarations 35 | 'no-func-assign': 'error', 36 | // Disallow variable or function declarations in nested blocks 37 | 'no-inner-declarations': 'error', 38 | // Disallow invalid regular expression strings in the RegExp constructor 39 | 'no-invalid-regexp': 'error', 40 | // Disallow irregular whitespace outside of strings and comments 41 | 'no-irregular-whitespace': 'error', 42 | // Disallow calling global object properties as functions 43 | 'no-obj-calls': 'error', 44 | // Disallow calling some Object.prototype methods directly on objects 45 | 'no-prototype-builtins': 'error', 46 | // Disallow multiple spaces in regular expressions 47 | 'no-regex-spaces': 'error', 48 | // Disallow sparse arrays 49 | 'no-sparse-arrays': 'error', 50 | // Disallow template literal placeholder syntax in regular strings 51 | 'no-template-curly-in-string': 'error', 52 | // Disallow unreachable statements after a return, throw, continue, or break statement 53 | 'no-unreachable': 'error', 54 | // Disallow control flow statements in finally blocks 55 | 'no-unsafe-finally': 'error', 56 | // Disallow negating the left operand of relational operators 57 | 'no-unsafe-negation': 'error', 58 | // Require calls to isNaN() when checking for NaN 59 | 'use-isnan': 'error', 60 | // Enforce comparing typeof expressions against valid strings 61 | 'valid-typeof': 'error', 62 | }, 63 | }; 64 | -------------------------------------------------------------------------------- /packages/eslint-config-base/lib/rules/es6.js: -------------------------------------------------------------------------------- 1 | // ECMAScript6 - http://eslint.org/docs/rules/#ecmascript-6 2 | 3 | 'use strict'; 4 | 5 | module.exports = { 6 | rules: { 7 | // Require braces around arrow function bodies 8 | 'arrow-body-style': ['error', 'as-needed'], 9 | // Require parentheses around arrow function arguments 10 | 'arrow-parens': ['error', 'always'], 11 | // Enforce consistent spacing before and after the arrow in arrow functions 12 | 'arrow-spacing': ['error', { before: true, after: true }], 13 | // Require super() calls in constructors 14 | 'constructor-super': 'error', 15 | // Enforce consistent spacing around * operators in generator functions 16 | 'generator-star-spacing': ['error', { before: false, after: true }], 17 | // Disallow reassigning class members 18 | 'no-class-assign': 'error', 19 | // Disallow reassigning const variables 20 | 'no-const-assign': 'error', 21 | // Disallow duplicate class members 22 | 'no-dupe-class-members': 'error', 23 | // Disallow duplicate module imports 24 | 'no-duplicate-imports': 'error', 25 | // Disallow new operators with the Symbol object 26 | 'no-new-symbol': 'error', 27 | // Disallow this/super before calling super() in constructors 28 | 'no-this-before-super': 'warn', 29 | // Disallow unnecessary computed property keys in object literals 30 | 'no-useless-computed-key': 'error', 31 | // Disallow unnecessary constructors 32 | 'no-useless-constructor': 'error', 33 | // Disallow renaming import, export, and destructured assignments to the same name 34 | 'no-useless-rename': 'error', 35 | // Require let or const instead of var 36 | 'no-var': 'error', 37 | // Require or disallow method and property shorthand syntax for object literals 38 | 'object-shorthand': ['error', 'always'], 39 | // Require arrow functions as callbacks 40 | 'prefer-arrow-callback': 'error', 41 | // Require const declarations for variables that are never reassigned after declared 42 | 'prefer-const': 'error', 43 | // Disallow parseInt() in favor of binary, octal, and hexadecimal literals 44 | 'prefer-numeric-literals': 'error', 45 | // Require rest parameters instead of arguments 46 | 'prefer-rest-params': 'error', 47 | // Require spread operators instead of .apply() 48 | 'prefer-spread': 'error', 49 | // Require template literals instead of string concatenation 50 | 'prefer-template': 'warn', 51 | // Require generator functions to contain yield 52 | 'require-yield': 'error', 53 | // Enforce spacing between rest and spread operators and their expressions 54 | 'rest-spread-spacing': ['error', 'never'], 55 | // Require or disallow spacing around embedded expressions of template strings 56 | 'template-curly-spacing': ['error', 'never'], 57 | // Require or disallow spacing around the * in yield* expressions 58 | 'yield-star-spacing': ['error', { before: false, after: true }], 59 | }, 60 | }; 61 | -------------------------------------------------------------------------------- /packages/eslint-config-react/test/rules/react-hooks.js: -------------------------------------------------------------------------------- 1 | import { useEffect, useState, useCallback, useRef } from 'react'; 2 | 3 | // `react-hooks/rules-of-hooks` - hooks must always be called at the top level 4 | // -------------------------------------------------------------------- 5 | // Bad 6 | { 7 | const Foo = ({ foo }) => { 8 | if (foo) { 9 | useState('foo'); 10 | } 11 | 12 | return null; 13 | }; 14 | } 15 | // Also bad 16 | { 17 | const Foo = () => { 18 | for (let x = 0; x < 5; x += 1) { 19 | useState('foo'); 20 | } 21 | 22 | return null; 23 | }; 24 | } 25 | // Still bad 26 | { 27 | const Foo = () => { 28 | const fn = () => { 29 | useState('foo'); 30 | }; 31 | 32 | return null; 33 | }; 34 | } 35 | // Good 36 | { 37 | const Foo = () => { 38 | useState('foo'); 39 | 40 | return null; 41 | }; 42 | } 43 | 44 | // `react-hooks/exhaustive-deps` - warns about effects not having their dependencies declared 45 | // -------------------------------------------------------------------- 46 | // Bad 47 | { 48 | const Foo = ({ value }) => { 49 | useEffect(() => { 50 | const plusOne = value + 1; 51 | }, []); 52 | 53 | return null; 54 | }; 55 | } 56 | // Good 57 | { 58 | const Foo = ({ value }) => { 59 | useEffect(() => { 60 | const plusOne = value + 1; 61 | }, [value]); 62 | 63 | return null; 64 | }; 65 | } 66 | 67 | // `react-hooks/rules-of-hooks` - custom hook names must be prefixed with "use" 68 | // -------------------------------------------------------------------- 69 | // Bad 70 | { 71 | const hook = () => { 72 | useState('foo'); 73 | }; 74 | 75 | const Foo = () => { 76 | hook(); 77 | 78 | return null; 79 | }; 80 | } 81 | // Good 82 | { 83 | const useHook = () => { 84 | useState('foo'); 85 | }; 86 | 87 | const Foo = () => { 88 | useHook(); 89 | 90 | return null; 91 | }; 92 | } 93 | 94 | // `react-hooks/exhaustive-deps` - warns about function references changing every render 95 | // -------------------------------------------------------------------- 96 | // Not advisable 97 | { 98 | const Foo = () => { 99 | const fn = () => {}; 100 | 101 | useEffect(() => { 102 | fn(); 103 | }, [fn]); 104 | 105 | return null; 106 | }; 107 | } 108 | // Good 109 | { 110 | const Foo = () => { 111 | const fn = useCallback(() => {}, []); 112 | 113 | useEffect(() => { 114 | fn(); 115 | }, [fn]); 116 | 117 | return null; 118 | }; 119 | } 120 | // `react-hooks/exhaustive-deps` - warns about preservation of most recent value 121 | // -------------------------------------------------------------------- 122 | // Not advisable 123 | { 124 | const Foo = ({ value }) => { 125 | let currentValue; 126 | 127 | useEffect(() => { 128 | currentValue = value; 129 | }, [value]); 130 | 131 | return null; 132 | }; 133 | } 134 | // Good 135 | { 136 | const Foo = ({ value }) => { 137 | const currentValueRef = useRef(value); 138 | 139 | useEffect(() => { 140 | currentValueRef.current = value; 141 | }, [value]); 142 | 143 | return null; 144 | }; 145 | } 146 | -------------------------------------------------------------------------------- /packages/eslint-config-react-web-a11y/lib/rules/jsx-a11y.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // React JSX a11y plugin - // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules 4 | 5 | module.exports = { 6 | rules: { 7 | // Enforce emojis are wrapped in and provide screen reader access 8 | 'jsx-a11y/accessible-emoji': 'warn', 9 | // Enforce all elements that require alternative text have meaningful information to relay back to end user 10 | 'jsx-a11y/alt-text': 'warn', 11 | // Enforce all anchors to contain accessible content 12 | 'jsx-a11y/anchor-has-content': 'warn', 13 | // Enforce all anchors are valid, navigable elements 14 | 'jsx-a11y/anchor-is-valid': 'warn', 15 | // Enforce elements with aria-activedescendant are tabbable 16 | 'jsx-a11y/aria-activedescendant-has-tabindex': 'warn', 17 | // Enforce all aria-* props are valid 18 | 'jsx-a11y/aria-props': 'error', 19 | // Enforce ARIA state and property values are valid 20 | 'jsx-a11y/aria-proptypes': 'error', 21 | // Enforce that elements with ARIA roles must use a valid, non-abstract ARIA role 22 | 'jsx-a11y/aria-role': 'error', 23 | // Enforce that elements that do not support ARIA roles, states, and properties do not have those attributes 24 | 'jsx-a11y/aria-unsupported-elements': 'warn', 25 | // Enforce a clickable non-interactive element has at least one keyboard event listener 26 | 'jsx-a11y/click-events-have-key-events': 'warn', 27 | // Enforce heading (h1, h2, etc) elements contain accessible content 28 | 'jsx-a11y/heading-has-content': 'warn', 29 | // Enforce element has lang prop 30 | 'jsx-a11y/html-has-lang': 'warn', 31 | // Enforce iframe elements have a title attribute 32 | 'jsx-a11y/iframe-has-title': 'warn', 33 | // Enforce alt prop does not contain the word "image", "picture", or "photo" 34 | 'jsx-a11y/img-redundant-alt': 'warn', 35 | // Enforce that elements with interactive handlers like onClick must be focusable 36 | 'jsx-a11y/interactive-supports-focus': 'warn', 37 | // Enforce that a label tag has a text label and an associated control 38 | 'jsx-a11y/label-has-associated-control': 'warn', 39 | // Enforce lang attribute has a valid value 40 | 'jsx-a11y/lang': 'error', 41 | // Enforces that