Skip to content

Commit

Permalink
Consolidate eslint setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk authored and marijnh committed Jan 3, 2022
1 parent b2e6ade commit 16dfa25
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 148 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
test
52 changes: 52 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict"

module.exports = {
extends: [
"eslint:recommended",
"standard",
"plugin:import/errors",
"plugin:import/warnings"
],
globals: {
BigInt: false,
Packages: false
},
overrides: [
{
files: ["acorn/src/bin/*.js", "bin/generate-identifier-regex.js"],
rules: {
"no-console": "off"
}
}
],
plugins: ["eslint-plugin-import"],
rules: {
curly: "off",
eqeqeq: ["error", "always", {null: "ignore"}],
indent: [
"error",
2,
{
SwitchCase: 0,
VariableDeclarator: 2,
CallExpression: {arguments: "off"}
}
],
"new-parens": "off",
"no-case-declarations": "off",
"no-cond-assign": "off",
"no-console": ["error", {allow: ["warn", "error"]}],
"no-fallthrough": "off",
"no-labels": "off",
"no-mixed-operators": "off",
"no-return-assign": "off",
"no-unused-labels": "error",
"no-var": "error",
"object-curly-spacing": ["error", "never"],
"one-var": "off",
"prefer-const": "off",
quotes: ["error", "double"],
"semi-spacing": "off",
"space-before-function-paren": ["error", "never"]
}
}
4 changes: 3 additions & 1 deletion acorn-loose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"./package.json": "./package.json"
},
"version": "8.3.0",
"engines": {"node": ">=0.4.0"},
"engines": {
"node": ">=0.4.0"
},
"dependencies": {
"acorn": "^8.5.0"
},
Expand Down
1 change: 0 additions & 1 deletion acorn-loose/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default {
file: "acorn-loose/dist/acorn-loose.js",
format: "umd",
name: "acorn.loose",

globals: {acorn: "acorn"}
},
{
Expand Down
34 changes: 0 additions & 34 deletions acorn-loose/src/.eslintrc

This file was deleted.

4 changes: 3 additions & 1 deletion acorn-walk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"./package.json": "./package.json"
},
"version": "8.2.0",
"engines": {"node": ">=0.4.0"},
"engines": {
"node": ">=0.4.0"
},
"maintainers": [
{
"name": "Marijn Haverbeke",
Expand Down
34 changes: 0 additions & 34 deletions acorn-walk/src/.eslintrc

This file was deleted.

8 changes: 6 additions & 2 deletions acorn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"./package.json": "./package.json"
},
"version": "8.7.0",
"engines": {"node": ">=0.4.0"},
"engines": {
"node": ">=0.4.0"
},
"maintainers": [
{
"name": "Marijn Haverbeke",
Expand All @@ -42,5 +44,7 @@
"scripts": {
"prepare": "cd ..; npm run build:main"
},
"bin": {"acorn": "./bin/acorn"}
"bin": {
"acorn": "./bin/acorn"
}
}
36 changes: 0 additions & 36 deletions acorn/src/.eslintrc

This file was deleted.

6 changes: 0 additions & 6 deletions acorn/src/bin/.eslintrc

This file was deleted.

16 changes: 8 additions & 8 deletions bin/generate-identifier-regex.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';
"use strict"

// Which Unicode version should be used?
let pkg = require('../package.json')
let pkg = require("../package.json")
let dependencies = Object.keys(pkg.devDependencies)
let unicodeVersion = dependencies.find((name) => /^@unicode\/unicode-\d/.test(name))

let start = require(unicodeVersion + '/Binary_Property/ID_Start/code-points.js').filter(ch => ch > 0x7f)
let start = require(unicodeVersion + "/Binary_Property/ID_Start/code-points.js").filter(ch => ch > 0x7f)
let last = -1
let cont = [0x200c, 0x200d].concat(require(unicodeVersion + '/Binary_Property/ID_Continue/code-points.js')
.filter(ch => ch > 0x7f && search(start, ch, last + 1) === -1))
let cont = [0x200c, 0x200d].concat(require(unicodeVersion + "/Binary_Property/ID_Continue/code-points.js")
.filter(ch => ch > 0x7f && search(start, ch, last + 1) === -1))

function search(arr, ch, starting) {
for (let i = starting; arr[i] <= ch && i < arr.length; last = i++)
Expand All @@ -25,7 +25,7 @@ function generate(chars) {
let astral = [], re = ""
for (let i = 0, at = 0x10000; i < chars.length; i++) {
let from = chars[i], to = from
while (i < chars.length - 1 && chars[i + 1] === to + 1) {i++; to++}
while (i < chars.length - 1 && chars[i + 1] === to + 1) { i++; to++ }
if (to <= 0xffff) {
if (from === to) re += esc(from)
else if (from + 1 === to) re += esc(from) + esc(to)
Expand All @@ -47,10 +47,10 @@ let code = [
` const astralIdentifierCodes = ${JSON.stringify(contData.astral)}`
]

if (process.argv.length != 3) {
if (process.argv.length !== 3) {
console.log(code.join("\n"))
} else {
let {readFile} = require('fs')
let {readFile} = require("fs")
readFile(process.argv[2], "utf8", function(err, data) {
if (err) throw err
for (let line of code)
Expand Down
10 changes: 4 additions & 6 deletions bin/run_test262.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ const parse = require("../acorn").parse

function loadList(filename) {
return fs.readFileSync(filename, "utf8")
.split("\n")
.filter(Boolean)
.split("\n")
.filter(Boolean)
}

run(
(content, {sourceType}) => parse(content, {sourceType, ecmaVersion: 13, allowHashBang: true, allowAwaitOutsideFunction: sourceType === "module"}),
{
testsDirectory: path.dirname(require.resolve("test262/package.json")),
skip: test => test.attrs.features &&
loadList("./bin/test262.unsupported-features").some(f => test.attrs.features.includes(f)
),
loadList("./bin/test262.unsupported-features").some(f => test.attrs.features.includes(f)),
whitelist: loadList("./bin/test262.whitelist")
.map(filename => path.sep === "/" ? filename : filename.split("/").join(path.sep)
)
.map(filename => path.sep === "/" ? filename : filename.split("/").join(path.sep))
}
)
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
},
"license": "MIT",
"scripts": {
"prepare": "npm run test",
"test": "node test/run.js && node test/lint.js",
"pretest": "npm run build:main && npm run build:loose",
"test:test262": "node bin/run_test262.js",
"build": "npm run build:main && npm run build:walk && npm run build:loose",
"build:loose": "rollup -c acorn-loose/rollup.config.js",
"build:main": "rollup -c acorn/rollup.config.js",
"build:walk": "rollup -c acorn-walk/rollup.config.js",
"build:loose": "rollup -c acorn-loose/rollup.config.js",
"lint": "eslint acorn/src/ acorn-walk/src/ acorn-loose/src/"
"lint": "eslint .",
"prepare": "npm run test",
"pretest": "npm run build:main && npm run build:loose",
"test": "node test/run.js && npm run lint",
"test:test262": "node bin/run_test262.js"
},
"devDependencies": {
"@rollup/plugin-buble": "^0.21.3",
Expand Down
13 changes: 0 additions & 13 deletions test/lint.js

This file was deleted.

0 comments on commit 16dfa25

Please sign in to comment.