Skip to content

Commit a3d341c

Browse files
committed
Remove standard in favour of eslint
Mostly because of unmaintained libraries in the Standard family and the upcoming migration to Vite Ref: - standard/standardx#42 - standard/eslint-config-standard#229 - standard/standard-loader#104
1 parent c89b01d commit a3d341c

File tree

6 files changed

+328
-622
lines changed

6 files changed

+328
-622
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/**/vendor/*.js
2+
/app/assets/config/**/*.js
3+
/config/**/*.js

.eslintrc.cjs

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
module.exports = {
2+
root: true,
3+
extends: [
4+
'plugin:import/errors',
5+
'plugin:import/warnings',
6+
'plugin:unicorn/recommended',
7+
'xo',
8+
'xo/browser'
9+
],
10+
rules: {
11+
'arrow-body-style': 'off',
12+
'capitalized-comments': 'off',
13+
'comma-dangle': [
14+
'error',
15+
'never'
16+
],
17+
'import/extensions': [
18+
'error',
19+
'ignorePackages',
20+
{
21+
js: 'always'
22+
}
23+
],
24+
'import/first': 'error',
25+
'import/newline-after-import': 'error',
26+
'import/no-absolute-path': 'error',
27+
'import/no-amd': 'error',
28+
'import/no-anonymous-default-export': [
29+
'error',
30+
{
31+
allowObject: true
32+
}
33+
],
34+
'import/no-cycle': [
35+
'error',
36+
{
37+
ignoreExternal: true
38+
}
39+
],
40+
'import/no-duplicates': 'error',
41+
'import/no-extraneous-dependencies': 'error',
42+
'import/no-mutable-exports': 'error',
43+
'import/no-named-as-default': 'error',
44+
'import/no-named-as-default-member': 'error',
45+
'import/no-named-default': 'error',
46+
'import/no-self-import': 'error',
47+
'import/no-unassigned-import': 'off',
48+
'import/no-useless-path-segments': 'error',
49+
'import/order': 'off',
50+
indent: [
51+
'error',
52+
2,
53+
{
54+
MemberExpression: 'off',
55+
SwitchCase: 1
56+
}
57+
],
58+
'max-params': [
59+
'warn',
60+
5
61+
],
62+
'multiline-ternary': [
63+
'error',
64+
'always-multiline'
65+
],
66+
'new-cap': [
67+
'error',
68+
{
69+
properties: false
70+
}
71+
],
72+
'no-console': 'error',
73+
'no-negated-condition': 'off',
74+
'object-curly-spacing': [
75+
'error',
76+
'always'
77+
],
78+
'operator-linebreak': [
79+
'error',
80+
'after'
81+
],
82+
'prefer-template': 'error',
83+
semi: [
84+
'error',
85+
'never'
86+
],
87+
strict: 'error',
88+
'unicorn/explicit-length-check': 'off',
89+
'unicorn/filename-case': 'off',
90+
'unicorn/no-array-callback-reference': 'off',
91+
'unicorn/no-array-method-this-argument': 'off',
92+
'unicorn/no-null': 'off',
93+
'unicorn/no-typeof-undefined': 'off',
94+
'unicorn/no-unused-properties': 'error',
95+
'unicorn/numeric-separators-style': 'off',
96+
'unicorn/prefer-array-flat': 'off',
97+
'unicorn/prefer-at': 'off',
98+
'unicorn/prefer-dom-node-dataset': 'off',
99+
'unicorn/prefer-module': 'off',
100+
'unicorn/prefer-query-selector': 'off',
101+
'unicorn/prefer-spread': 'off',
102+
'unicorn/prefer-string-replace-all': 'off',
103+
'unicorn/prevent-abbreviations': 'off'
104+
},
105+
settings: {
106+
'import/resolver': {
107+
node: {
108+
paths: ['app/javascript']
109+
}
110+
}
111+
}
112+
}

config/webpack/development.js

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1+
const ESLintPlugin = require('eslint-webpack-plugin')
12
const StyleLintPlugin = require('stylelint-webpack-plugin')
23

34
module.exports = {
45
envSpecificConfig: {
5-
module: {
6-
rules: [
7-
{
8-
test: /\.js$/,
9-
exclude: /vendor\/.+\.js$/,
10-
loader: 'standard-loader',
11-
options: {
12-
globals: [
13-
'$'
14-
]
15-
}
16-
}
17-
]
18-
},
196
plugins: [
7+
new ESLintPlugin({
8+
failOnError: false,
9+
files: 'app/javascript/**/*.js',
10+
exclude: 'app/javascript/src/vendor/**/*.js'
11+
}),
2012
new StyleLintPlugin({
2113
failOnError: false,
2214
files: 'app/javascript/**/*.(s(c|a)ss|css)'

lib/tasks/yarn_linters.rake

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ namespace :yarn do
2424
Rake::Task['yarn:run'].execute(command: "stylelint #{Dir.glob('app/**/*.scss').join(' ')}")
2525
end
2626

27-
desc 'Run `bin/yarn standard`'
28-
task :standard do
29-
Rake::Task['yarn:run'].execute(command: 'standard')
27+
desc 'Run `bin/yarn eslint`'
28+
task :eslint do
29+
Rake::Task['yarn:run'].execute(command: 'eslint app/**/*.js')
3030
end
3131
# rubocop:enable Rails/RakeEnvironment
3232
end
3333

3434
task(:lint).sources.push 'yarn:stylelint'
35-
task(:lint).sources.push 'yarn:standard'
35+
task(:lint).sources.push 'yarn:eslint'

package.json

+5-12
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,18 @@
4747
"@babel/eslint-parser": "^7.23.3",
4848
"@types/express": "^4.17.21",
4949
"@webpack-cli/serve": "^2.0.4",
50-
"eslint": "^8.56.0",
51-
"standard": "^16.0.3",
52-
"standard-loader": "^7.0.0",
50+
"eslint": ">=8.27.0",
51+
"eslint-config-xo": "^0.43.1",
52+
"eslint-plugin-import": "^2.29.1",
53+
"eslint-plugin-unicorn": "^50.0.1",
54+
"eslint-webpack-plugin": "^4.0.1",
5355
"stylelint": "^15.11.0",
5456
"stylelint-config-twbs-bootstrap": "^12.0.0",
5557
"stylelint-order": "^6.0.4",
5658
"stylelint-scss": "^5.3.2",
5759
"stylelint-webpack-plugin": "^4.1.1",
5860
"webpack-dev-server": "^4.15.1"
5961
},
60-
"standard": {
61-
"parser": "@babel/eslint-parser",
62-
"ignore": [
63-
"/*.js",
64-
"app/assets/javascripts",
65-
"app/javascript/src/vendor",
66-
"/config"
67-
]
68-
},
6962
"babel": {
7063
"presets": [
7164
"./node_modules/shakapacker/package/babel/preset.js"

0 commit comments

Comments
 (0)