Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aladdin-add/eslint-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eslint-plugin-web-v0.1.0
Choose a base ref
...
head repository: aladdin-add/eslint-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: eslint-plugin-web-v0.2.0
Choose a head ref
  • 5 commits
  • 13 files changed
  • 3 contributors

Commits on Jul 1, 2024

  1. feat: add no-new-native-nonconstructor (#93)

    SukkaW authored Jul 1, 2024
    Copy the full SHA
    63ecdd4 View commit details
  2. chore: release master (#95)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored Jul 1, 2024
    Copy the full SHA
    bffb9b0 View commit details

Commits on Jul 8, 2024

  1. refactor: drop lodash (#96)

    SukkaW authored Jul 8, 2024
    Copy the full SHA
    4f9edc2 View commit details

Commits on Sep 2, 2024

  1. feat: add pkg.meta, config.name for better DX (#99)

    aladdin-add authored Sep 2, 2024
    Copy the full SHA
    2557d60 View commit details
  2. chore: release master (#100)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored Sep 2, 2024
    Copy the full SHA
    02072ec View commit details
6 changes: 3 additions & 3 deletions .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages/autofix": "2.0.0",
"packages/no-autofix": "2.0.0",
"packages/web": "0.1.0"
"packages/autofix": "2.2.0",
"packages/no-autofix": "2.1.0",
"packages/web": "0.2.0"
}
15 changes: 14 additions & 1 deletion packages/autofix/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [2.2.0](https://github.com/aladdin-add/eslint-plugin/compare/eslint-plugin-autofix-v2.1.0...eslint-plugin-autofix-v2.2.0) (2024-09-02)


### Features

* add pkg.meta, config.name for better DX ([#99](https://github.com/aladdin-add/eslint-plugin/issues/99)) ([2557d60](https://github.com/aladdin-add/eslint-plugin/commit/2557d60204c28e305ff9f9e9dad57c7fe595d873))

## [2.1.0](https://github.com/aladdin-add/eslint-plugin/compare/eslint-plugin-autofix-v2.0.0...eslint-plugin-autofix-v2.1.0) (2024-07-01)


### Features

* add `no-new-native-nonconstructor` ([#93](https://github.com/aladdin-add/eslint-plugin/issues/93)) ([63ecdd4](https://github.com/aladdin-add/eslint-plugin/commit/63ecdd487312f8ceb98625d47328562d18c20d8b))

## [2.0.0](https://github.com/aladdin-add/eslint-plugin/compare/eslint-plugin-autofix-v1.1.0...eslint-plugin-autofix-v2.0.0) (2024-05-02)


@@ -10,4 +24,3 @@
### Features

* support eslint v9 & requires node &gt;= 18 ([066e38c](https://github.com/aladdin-add/eslint-plugin/commit/066e38c866771b25fa3f09df69c71d603390e20e))

14 changes: 8 additions & 6 deletions packages/autofix/lib/index.js
Original file line number Diff line number Diff line change
@@ -8,8 +8,10 @@ const all = require("./configs/all");
const recommended = require("./configs/recommended");
const unsafe = require("./configs/unsafe");
const rules = require("./rules");
const pkg = require("../package.json");

const pkg = {
const plugin = {
meta: { name: pkg.name, version: pkg.version },
configs: {
all,
recommended,
@@ -18,10 +20,10 @@ const pkg = {
rules
};

Object.assign(pkg.configs, {
"flat/all": { ...pkg.configs.all, plugins: { autofix: pkg }, rules: pkg.configs.all.rules },
"flat/recommended": { ...pkg.configs.recommended, plugins: { autofix: pkg }, rules: pkg.configs.recommended.rules },
"flat/unsafe": { ...pkg.configs.unsafe, plugins: { autofix: pkg }, rules: pkg.configs.unsafe.rules }
Object.assign(plugin.configs, {
"flat/all": { name: "eslint-plugin-autofix/all", ...plugin.configs.all, plugins: { autofix: plugin }, rules: plugin.configs.all.rules },
"flat/recommended": { name: "eslint-plugin-autofix/recommended", ...plugin.configs.recommended, plugins: { autofix: plugin }, rules: plugin.configs.recommended.rules },
"flat/unsafe": { name: "eslint-plugin-autofix/unsafe", ...plugin.configs.unsafe, plugins: { autofix: plugin }, rules: plugin.configs.unsafe.rules }
});

module.exports = pkg;
module.exports = plugin;
22 changes: 22 additions & 0 deletions packages/autofix/lib/rules/no-new-native-nonconstructor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @fileoverview Add fixer to rule no-new-native-nonconstructor.
* @author SukkaW <github@skk.moe>
*/
"use strict";

const ruleComposer = require("eslint-rule-composer");
const utils = require("../utils");

const rule = utils.getFixableRule("no-new-native-nonconstructor", true);

module.exports = ruleComposer.mapReports(
rule,
problem => {
problem.fix = fixer => {
const parent = problem.node.parent;

return fixer.removeRange([parent.range[0], parent.range[0] + 4]);
};
return problem;
}
);
3 changes: 1 addition & 2 deletions packages/autofix/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-autofix",
"version": "2.0.0",
"version": "2.2.0",
"author": "薛定谔的猫 <weiran.zsd@outlook.com>",
"description": "autofix some errors reported by eslint rules.",
"main": "./lib/index.js",
@@ -19,7 +19,6 @@
"eslint-rule-composer": "^0.3.0",
"espree": "^9.0.0",
"esutils": "^2.0.2",
"lodash": "^4.17.20",
"string-similarity": "^4.0.3"
},
"devDependencies": {
37 changes: 37 additions & 0 deletions packages/autofix/tests/lib/rules/no-new-native-nonconstructor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @fileoverview Tests for rule no-new-native-nonconstructor
* @author SukkaW <github@skk.moe>
*/
"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

const rule = require("../../../lib/rules/no-new-native-nonconstructor.js");
const RuleTester = require("../../rule-tester.js").RuleTester;

//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------

const ruleTester = new RuleTester();

ruleTester.run("no-new-native-nonconstructor", rule, {
valid: [
"Symbol('a')",
"BigInt(42)"
],
invalid: [
{
code: "new Symbol('a')",
output: "Symbol('a')",
errors: 1
},
{
code: "new BigInt(0x721)",
output: "BigInt(0x721)",
errors: 1
}
]
});
8 changes: 7 additions & 1 deletion packages/no-autofix/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [2.1.0](https://github.com/aladdin-add/eslint-plugin/compare/eslint-plugin-no-autofix-v2.0.0...eslint-plugin-no-autofix-v2.1.0) (2024-09-02)


### Features

* add pkg.meta, config.name for better DX ([#99](https://github.com/aladdin-add/eslint-plugin/issues/99)) ([2557d60](https://github.com/aladdin-add/eslint-plugin/commit/2557d60204c28e305ff9f9e9dad57c7fe595d873))

## [2.0.0](https://github.com/aladdin-add/eslint-plugin/compare/eslint-plugin-no-autofix-v1.2.3...eslint-plugin-no-autofix-v2.0.0) (2024-05-02)


@@ -10,4 +17,3 @@
### Features

* support eslint v9 & requires node &gt;= 18 ([066e38c](https://github.com/aladdin-add/eslint-plugin/commit/066e38c866771b25fa3f09df69c71d603390e20e))

10 changes: 6 additions & 4 deletions packages/no-autofix/lib/index.js
Original file line number Diff line number Diff line change
@@ -6,16 +6,18 @@

const all = require("./configs/all");
const rules = require("./rules");
const pkg = require("../package.json");

const pkg = {
const plugin = {
meta: { name: pkg.name, version: pkg.version },
configs: {
all
},
rules
};

Object.assign(pkg.configs, {
"flat/all": { plugins: { "no-autofix": pkg }, rules: pkg.configs.all.rules }
Object.assign(plugin.configs, {
"flat/all": { name: "eslint-plugin-no-autofix/all", plugins: { "no-autofix": plugin }, rules: plugin.configs.all.rules }
});

module.exports = pkg;
module.exports = plugin;
2 changes: 1 addition & 1 deletion packages/no-autofix/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-no-autofix",
"version": "2.0.0",
"version": "2.1.0",
"author": "薛定谔的猫 <weiran.zsd@outlook.com>",
"description": "eslint rules without fixer.",
"main": "./lib/index.js",
7 changes: 7 additions & 0 deletions packages/web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.2.0](https://github.com/aladdin-add/eslint-plugin/compare/eslint-plugin-web-v0.1.0...eslint-plugin-web-v0.2.0) (2024-09-02)


### Features

* add pkg.meta, config.name for better DX ([#99](https://github.com/aladdin-add/eslint-plugin/issues/99)) ([2557d60](https://github.com/aladdin-add/eslint-plugin/commit/2557d60204c28e305ff9f9e9dad57c7fe595d873))

## [0.1.0](https://github.com/aladdin-add/eslint-plugin/compare/eslint-plugin-web-v0.0.3...eslint-plugin-web-v0.1.0) (2024-05-02)


51 changes: 26 additions & 25 deletions packages/web/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
/**
* @fileoverview eslint-plugin-web
* @author 唯然<weiran.zsd@outlook.com>
*/
"use strict";

const ruleIds = ["no-alert", "no-script-url"];
const all = {};
const rules = {};

for (const ruleId of ruleIds) {
all[ruleId] = 2;
rules[ruleId] = require(`../lib/rules/${ruleId}.js`);
}

module.exports = {
configs: {
all: {
plugins: ["web"],
rules: all
}

},
rules
};
/**
* @fileoverview eslint-plugin-web
* @author 唯然<weiran.zsd@outlook.com>
*/
"use strict";
const pkg = require("../package.json");
const ruleIds = ["no-alert", "no-script-url"];
const all = {};
const rules = {};

for (const ruleId of ruleIds) {
all[ruleId] = 2;
rules[ruleId] = require(`../lib/rules/${ruleId}.js`);
}

module.exports = {
meta: { name: pkg.name, version: pkg.version },
configs: {
all: {
plugins: ["web"],
rules: all
}

},
rules
};
4 changes: 2 additions & 2 deletions packages/web/lib/utils.js
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

const esutils = require("esutils");
const espree = require("espree");
const lodash = require("lodash");
const escapeStringRegexp = require("escape-string-regexp");

const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/u;
const lineBreakPattern = /\r\n|[\r\n\u2028\u2029]/u;
@@ -1312,7 +1312,7 @@ module.exports = {
* @returns {SourceLocation} The `loc` object.
*/
getNameLocationInGlobalDirectiveComment(sourceCode, comment, name) {
const namePattern = new RegExp(`[\\s,]${lodash.escapeRegExp(name)}(?:$|[\\s,:])`, "gu");
const namePattern = new RegExp(`[\\s,]${escapeStringRegexp(name)}(?:$|[\\s,:])`, "gu");

// To ignore the first text "global".
namePattern.lastIndex = comment.value.indexOf("global") + 6;
4 changes: 2 additions & 2 deletions packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-web",
"version": "0.1.0",
"version": "0.2.0",
"author": "唯然<weiran.zsd@outlook.com",
"description": "Additional ESLint's rules for web.",
"main": "./lib/index.js",
@@ -29,7 +29,7 @@
"dependencies": {
"espree": "^7.3.1",
"esutils": "^2.0.3",
"lodash": "^4.17.20"
"escape-string-regexp": "^4.0.0"
},
"peerDependencies": {
"eslint": ">4"