From c3084e6bbdc439f633bc77eae32a49d1f37ae00a Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 11 Dec 2018 16:15:06 +0300 Subject: [PATCH] chore: prepare `94.0.0` release --- CHANGELOG.md | 12 +++++++++++ README.md | 28 +++++-------------------- __tests__/index.js | 50 +++++++------------------------------------- index.js | 9 +------- lib/config/ava.js | 5 ++--- lib/config/core.js | 50 -------------------------------------------- lib/config/es5.js | 7 ------- lib/config/esnext.js | 44 ++++++++++++++++++++++++++++++++++---- lib/config/html.js | 3 --- lib/config/jest.js | 2 +- lib/config/react.js | 6 ------ package-lock.json | 2 +- package.json | 2 +- 13 files changed, 70 insertions(+), 150 deletions(-) delete mode 100644 lib/config/core.js delete mode 100644 lib/config/es5.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 745ddbe..e806564 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org). Except add new rule (it is breaking changed by default). +## 94.0.0 - 2018-12-11 + +- Changed: move `unicorn` rules into `esnext` preset. +- Changed: remove `sourceType` from `react` preset. +- Changed: remove `es6` from `jest` preset. +- Changed: remove `es6` from `ava` preset. +- Changed: remove `es6` from `html` preset. +- Fixed: add `jest/globals` to `jest` preset. +- Removed: `globals` from `react` preset. +- Removed: `es5` preset (use `babel` to transpile code in `es5`/`es3` and etc). +- Removed: `core` preset. + ## 93.0.0 - 2018-12-11 - Added: `react/forbid-foreign-prop-types` rule. diff --git a/README.md b/README.md index 49ffe5b..9b2fc19 100644 --- a/README.md +++ b/README.md @@ -57,15 +57,7 @@ React-specific rules to those in the ESNext config): ```json { - "extends": "plugin:itgalaxy/react" -} -``` - -If working on an ES5 project, extend the ES5 version of the configuration: - -```json -{ - "extends": "plugin:itgalaxy/es5" + "extends": ["plugin:itgalaxy/esnext", "plugin:itgalaxy/react"] } ``` @@ -80,25 +72,17 @@ following configuration file: "plugin:itgalaxy/esnext", "plugin:itgalaxy/react", "plugin:itgalaxy/lodash", - "plugin:itgalaxy/mocha" + "plugin:itgalaxy/jest" ] } ``` -Notice: presets **"plugin:itgalaxy/esnext"** or **"plugin:itgalaxy/es5"** always should be **first**. +Notice: presets **"plugin:itgalaxy/esnext"** should be **first**. ## Provided configurations This plugin provides the following core configurations: -- [es5](lib/config/es5.js): Use this for legacy projects. - -```json -{ - "extends": ["plugin:itgalaxy/es5"] -} -``` - - [esnext](lib/config/esnext.js): Use this for anything written with ES2015+ features. ```json @@ -145,7 +129,7 @@ module.exports = { }; ``` -- [node](lib/config/node.js): Use this for nodejs projects. +- [node](lib/config/node.js): Use this for `nodejs` projects. Example: @@ -155,7 +139,7 @@ Example: } ``` -- [react](lib/config/react.js): Use this for React projects. +- [react](lib/config/react.js): Use this for `React` projects. Example: @@ -167,8 +151,6 @@ Example: - [all](lib/config/all.js): Don't use. It is for internal purposes (testings and tools). -- [core](lib/config/core.js): Don't use. It is for internal purposes (testings and tools). - This plugin also provides the following tool-specific configurations, which can be used on top of the core configurations: - [AVA](lib/config/ava.js): Use this for projects that use the diff --git a/__tests__/index.js b/__tests__/index.js index 7dddf9e..4d10b5b 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -101,51 +101,15 @@ test("should load the `ava` plugin config in `eslint` to validate all rule synta t.is(report.warningCount, 0, "eslint report without warnings"); }); -test("should load the `core` plugin config in `eslint` to validate all rule syntax is correct", t => { - const config = Object.assign({}, configs.core); - const hasUnicornPlugin = config.plugins.indexOf("unicorn") !== -1; - const hasImportPlugin = config.plugins.indexOf("import") !== -1; - - t.true(hasUnicornPlugin, "there is unicorn plugin"); - t.true(hasImportPlugin, "there is import plugin"); - - const cli = new eslint.CLIEngine({ - baseConfig: config, - useEslintrc: false - }); - - const report = cli.executeOnText( - '(function() {\n "use strict";\n\n (123).toString();\n})();\n', - "test.js" - ); - - t.is(report.results.length, 1, "eslint report with one results"); - t.is(report.errorCount, 0, "eslint report without errors"); - t.is(report.warningCount, 0, "eslint report without warnings"); -}); - -test("should load the `es5` plugin config in eslint to validate all rule syntax is correct", t => { - const config = Object.assign({}, configs.es5); - const cli = new eslint.CLIEngine({ - baseConfig: config, - useEslintrc: false - }); - - const report = cli.executeOnText( - '(function() {\n "use strict";\n\n (123).toString();\n})();\n', - "test.js" - ); - - t.is(report.results.length, 1, "eslint report with one results"); - t.is(report.errorCount, 0, "eslint report without errors"); - t.is(report.warningCount, 0, "eslint report without warnings"); -}); - test("should load the `esnext` plugin config in `eslint` to validate all rule syntax is correct", t => { const config = Object.assign({}, configs.esnext); + const hasUnicornPlugin = config.plugins.indexOf("unicorn") !== -1; const hasPromisePlugin = config.plugins.indexOf("promise") !== -1; + const hasImportPlugin = config.plugins.indexOf("import") !== -1; + t.true(hasUnicornPlugin, "there is unicorn plugin"); t.true(hasPromisePlugin, "there is promise plugin"); + t.true(hasImportPlugin, "there is import plugin"); config.extends = []; @@ -155,7 +119,7 @@ test("should load the `esnext` plugin config in `eslint` to validate all rule sy }); const report = cli.executeOnText( - "let foo = 0;\n\n foo += 1;\n", + "/* global func */\nlet foo = 0;\n\n foo += 1;\n\nfunc(foo);", "test.js" ); @@ -220,7 +184,7 @@ test("should load the `react` plugin config in `eslint` to validate all rule syn const report = cli.executeOnText( ` -import React from "react"; +const React = require("react"); class Clock extends React.Component { render() { @@ -233,7 +197,7 @@ class Clock extends React.Component { } } -export default Clock; +module.exports = Clock; `, "test.jsx" diff --git a/index.js b/index.js index 9c55499..48ac4fe 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,6 @@ const all = require("./lib/config/all"); const ava = require("./lib/config/ava"); -const core = require("./lib/config/core"); -const es5 = require("./lib/config/es5"); const esnext = require("./lib/config/esnext"); const html = require("./lib/config/html"); const jest = require("./lib/config/jest"); @@ -16,8 +14,6 @@ const utils = require("./lib/utils"); const configs = { all, ava, - core, - es5, esnext, html, jest, @@ -27,7 +23,4 @@ const configs = { react }; -module.exports = { - configs, - utils -}; +module.exports = { configs, utils }; diff --git a/lib/config/ava.js b/lib/config/ava.js index ee74286..54ada28 100644 --- a/lib/config/ava.js +++ b/lib/config/ava.js @@ -3,9 +3,8 @@ const avaRules = require("./rules/ava"); module.exports = { - env: { - es6: true - }, + // `AVA` use own `babel` preset what support es6 syntax with `import` but we disable this because + // you can configure `babel` for `es3`, `es5`, `es6` and other `es` editions. plugins: ["ava"], rules: Object.assign({}, avaRules) }; diff --git a/lib/config/core.js b/lib/config/core.js deleted file mode 100644 index 7fca25a..0000000 --- a/lib/config/core.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; - -const bestPracticesRules = require("./rules/best-practices"); -const deprecatedRules = require("./rules/deprecated"); -const possibleErrorsRules = require("./rules/possible-errors"); -const strictModeRules = require("./rules/strict-mode"); -const stylisticIssuesRules = require("./rules/stylistic-issues"); -const variablesRules = require("./rules/variables"); -const importRules = require("./rules/import"); -const unicornRules = require("./rules/unicorn"); - -module.exports = { - plugins: ["import", "unicorn"], - env: { - es6: false - }, - parser: "babel-eslint", - parserOptions: { - ecmaVersion: 5, - sourceType: "script" - }, - settings: { - "import/resolver": { - node: { - extensions: [ - ".mjs", - ".js", - ".jsx", - ".json", - ".web.js", - ".ios.js", - ".android.js" - ] - } - }, - "import/ignore": ["\\.(coffee|scss|css|less|hbs|svg|json)$"], - "import/extensions": [".mjs", ".js", ".jsx"] - }, - rules: Object.assign( - {}, - possibleErrorsRules, - bestPracticesRules, - strictModeRules, - variablesRules, - stylisticIssuesRules, - deprecatedRules, - importRules, - unicornRules - ) -}; diff --git a/lib/config/es5.js b/lib/config/es5.js deleted file mode 100644 index 1e4c319..0000000 --- a/lib/config/es5.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -const path = require("path"); - -module.exports = { - extends: path.resolve(__dirname, "./core.js") -}; diff --git a/lib/config/esnext.js b/lib/config/esnext.js index d6e2159..c560c0d 100644 --- a/lib/config/esnext.js +++ b/lib/config/esnext.js @@ -1,19 +1,55 @@ "use strict"; -const path = require("path"); +const possibleErrorsRules = require("./rules/possible-errors"); +const bestPracticesRules = require("./rules/best-practices"); +const strictModeRules = require("./rules/strict-mode"); +const variablesRules = require("./rules/variables"); +const stylisticIssuesRules = require("./rules/stylistic-issues"); +const deprecatedRules = require("./rules/deprecated"); const ecmascript6Rules = require("./rules/ecmascript-6"); const promiseRules = require("./rules/promise"); +const unicornRules = require("./rules/unicorn"); +const importRules = require("./rules/import"); module.exports = { env: { es6: true }, + parser: "babel-eslint", parserOptions: { ecmaVersion: 2019, sourceType: "module", allowImportExportEverywhere: true }, - plugins: ["promise"], - extends: [path.resolve(__dirname, "./core.js")], - rules: Object.assign({}, ecmascript6Rules, promiseRules) + settings: { + "import/resolver": { + node: { + extensions: [ + ".mjs", + ".js", + ".jsx", + ".json", + ".web.js", + ".ios.js", + ".android.js" + ] + } + }, + "import/ignore": ["\\.(coffee|scss|css|less|hbs|svg|json)$"], + "import/extensions": [".mjs", ".js", ".jsx"] + }, + plugins: ["unicorn", "promise", "import"], + rules: Object.assign( + {}, + possibleErrorsRules, + bestPracticesRules, + strictModeRules, + variablesRules, + stylisticIssuesRules, + deprecatedRules, + ecmascript6Rules, + unicornRules, + promiseRules, + importRules + ) }; diff --git a/lib/config/html.js b/lib/config/html.js index 52ce29f..658ca35 100644 --- a/lib/config/html.js +++ b/lib/config/html.js @@ -1,8 +1,5 @@ "use strict"; module.exports = { - env: { - browser: true - }, plugins: ["html"] }; diff --git a/lib/config/jest.js b/lib/config/jest.js index 51cd505..63052e8 100644 --- a/lib/config/jest.js +++ b/lib/config/jest.js @@ -3,7 +3,7 @@ const jestRules = require("./rules/jest"); module.exports = { - env: { es6: true }, + env: { "jest/globals": true }, plugins: ["jest"], rules: Object.assign({}, jestRules) }; diff --git a/lib/config/react.js b/lib/config/react.js index 3dd24b9..0b25f80 100644 --- a/lib/config/react.js +++ b/lib/config/react.js @@ -9,17 +9,11 @@ module.exports = { }, parserOptions: { ecmaVersion: 2019, - sourceType: "module", ecmaFeatures: { jsx: true }, allowImportExportEverywhere: true }, - globals: { - fetch: true, - ReactElement: true, - ReactClass: true - }, settings: { react: { pragma: "React", diff --git a/package-lock.json b/package-lock.json index a27f762..753f23c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-itgalaxy", - "version": "93.0.0", + "version": "94.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c9016a6..3a5f9d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-itgalaxy", - "version": "93.0.0", + "version": "94.0.0", "description": "Itgalaxy org's ESLint rules and configs.", "keywords": [ "eslint",